Multi criteria dlookup issue - ms-access

I have spent some time working this Dlookup but to no avail.
Looked online and as far as I am aware this is right.
= DLookUp("F5","tbl_Backlog","[F30]="N" AND [F9]='" & [Form]![Text166] & "'")
Thanks in advance

Your criteria section looks to be incorrect.
= DLookUp("[F5]","tbl_Backlog","[F30]='N' AND [F9]='" & [Form]![Text166] & "'")

Related

Using textbox to update another text box in MS Access

I am trying to update a textbox#2 based on the value in Textbox#1.
The value in the textbox#1 is taken from from a string using " Mid([ScantheCode],1,10)" from ScantheCode box. I have tried couple of things but I am getting #error or #name.
I am using
=(DLookUp("ProductName","List","ProductN=" & [Textbox#1] & "'"))
Please help me find the solution for it.
Thank you,
regards,
Rohan
ProductN is probably text, so try inserting the missing quote:
=DLookUp("ProductName","List","ProductN = '" & [Textbox#1] & "'")

Access 2010 txt Search Box to Search multiple fields?

I have multiple combo & text boxes to search for different values in my main table on my front end. The code is as follows, just replicated for different types etc. This all works fine.
If Not IsNull(Me.strSearch) Then
strWhere = strWhere & "([tbl_Main.Description] Like ""*" & Me.strSearch & "*"") AND "
End If
My Problem is, I'm trying to create a text box which searches 2 columns simultaneously in my tbl_Main (tbl_Main.LessonsLearnt & tbl_Main.RecommendedAction) but can't figure out how to modify my current code to add another column in, searchable from the same textbox.
Disclaimer: I'm very much a beginner in MS Access - so please keep the explanation as simple as possible :D
If you need any other info - just let me know!
Thanks in advance
strWhere = strWhere & "(tbl_Main.Description Like '*" & Me.strSearch & "*' OR tbl_Main.OtherField Like '*" & Me.strSearch & "*') AND "
This will search for the strSearch being in either Desscription or OtherField. I also replaced your double double quotes with single quotes for better code readability and cross compatibility with other DBMS and removed the brackets that are only needed if you have spaces in your table/field names (something you really should never do anyway).

Errors in DLookup as a control source in access form

I have a text box with the control source of Dlookup function. But the Dlookup format makes me crazy, I tried a hundred times to refer another combo box value as criteria in Dlookup function. I got either "# name?" or "# Error".
I tried this:
=DLookUp("[Contact]","Supllier","[Company]='" & [Forms]![PurchaseOrder]![cboSupplierCompany] & "'")
and got "# Error"
when I input :
=DLookUp("[Contact]","Supllier","[Company]='" & [Me]![cboSupplierCompany] & "'")
I got "# Name?"
I finally found the solution. The right way to use Dlookup in a expression is to use the expression editor to select table field and form control.
the working expression of Dlookup in my textbox is :
DLookUp(" [Supplier]![Contact] ","Supplier"," [Supplier]![Company] ='" & [cboSupplierCompany] & "'")
Using a SQL-query window above-like versions work fine.
But they did not work in the ControlSource property setting. Here you have to use semicolons (;) instead of commas (,). At least in a German language settings environment. The control setting in German is:
Steuerelementinhalt
= DLookUp(" [Supplier]![Contact] ";"Supplier";" [Supplier]![Company] ='" & [cboSupplierCompany] & "'"

MS Access Filter Form with DateTimePicker

I need a little help.
I've created a textbox where i can set a date via DateTimePicker.
What i'd like to do is when i select 28.05.2016, the form should only display this date.
Can anyone help me out?
Edit
i tried this onUpdate
DoCmd.ApplyFilter , "[Date] like '*" & DateSelector & "*'"
I would rather use AfterUpdate event, the use
DoCmd.ApplyFilter , "[Date] = [forms].[myForm].[myControl]"
Like has little interest here since a partial entry of the date would trigger an error.
Alternatively you can use
DoCmd.ApplyFilter , "[Date] = " & Format([myControl], "\#mm/dd/yyyy\#")

Vba Access error: Method or data member not found

I have been trying to open a contracts form from contracts_all page. I want to open all the records on the contracts_all form but only show the specific one clicked on. To show this one particular record, the button uses ID found in the contracts_all form.
I have managed to go this far with the help of various people in different forums but now I am getting an error which says "Compiler error; Method or data member not found"..
Please help!
Thanks in advance.
Dim Rs As Recordset
Dim Test As Integer
Dim varBookmark As Variant
DoCmd.OpenForm "Contracts"
Set Rs = Forms!Contracts.RecordsetClone
Rs.FindFirst ("[ID] = '" & Me![ID] & "'")
varBookmark = Rs.Bookmark
Forms!Contracts.Form.Bookmark = varBookmark
If Rs.NoMatch Then
MsgBox "That does not exist in this database."
Else
End If
It looks like you may not have the appropriate references set. Make sure you have Microsoft DAO checked. Note that these methods will not work in ADO. :-)
Click Tools, then References, then Microsoft DAO 3.6 (or highest version available). Not having the correct library referenced is easy to miss if you copied and pasted code into your project.
Cheers,
LC
Try replacing
Rs.FindFirst ("[ID] = '" & Me![ID] & "'")
with
Rs.FindFirst ("[ID] = '" & Forms!contracts_all![ID] & "'")
That may be slightly off, but I'm guessing it's because your active form has changed from contracts_all to Contracts, so you can no longer use the Me! reference.
Another possibility is that the fields you are attempting to clear are set to Date or Number format, for example, which was the case in my database. I did learn a lot from looking through numerous threads on this topic though!