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] & "'")
Related
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] & "'")
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).
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] & "'"
How do I incorporate a mysql query into a messagebox in vba. What I want to do is when a user sends data into the database using dgv. How can I get a messagebox to show how many records are going in as updatse and how many are going in as inserts.
FYI I am using on duplicate key update function.
Thanks
It might help to see a little bit of your code, but you just need to set up a variable represent each element you want to display (say nUpdates and nInserts). Then just display that variable in the message box:
MsgBox("Records going in as updates:" & nUpdates & vbNewLine & vbNewLine & _
"Records going in as inserts:" & nInserts)
here is my code:
Text22 = DLookup("[Program_No]", "1_Supportive_Housing", "[Program_Name] = '" & Replace([Me.Program_Name], "'", "''") & "' And [BudgetYear] = " & [Me.BudgetYear])
I am not sure what is wrong with it, but it keeps giving me the following error:
Can't find the field | in your expression
I have been trying to get rid of this error but nothing works.
OnKeyPress, this event triggers. As the user writes, it should be able to lookup the value in the table and assign it to text22.
Looks like you want to reference to form fields [Me.Program_Name] & [Me.BudgetYear], but Access tries to find fields with exactly this name, including "Me." prefix. Try to remove brackets at all, or use Me.[Program_Name] and Me.[BudgetYear] instead.