Solved syntax error with form

ClaraBarton

Registered User.
Local time
Yesterday, 18:22
Joined
Oct 14, 2019
Messages
605
I'm trying to get an ID from a table and the criteria isn't right. If I use frm.name, it returns "frm.name = "frmCheck".
Code:
Dim frm as Form
From Calling Form: me
CallsID = DLookup("CBOCallsID", "tblCBOCalls", "CallingForm =" & frm(name))
This returns name = "Microsoft Access" --- Forms.frm.name.Value ; nope
How do I get just plain "frmCheck"?
 
Last edited:
If there is an ID in a table, why are you asking a form anything?

However, assuming that the table is set up to return a name, that is text. So the syntax MIGHT require something like this...

Code:
CallsID = DLookup("CBOCallsID", "tblCBOCalls", "CallingForm = '" & frm(name) & "'")

You have a case of a quoted string but you aren't maintaining the quotes around the name correctly. The normal way is to use apostrophes inside the quoted string so that the single-quote marks get passed along to maintain the quoted nature of what is clearly supposed to be a text string.
 
can't find the field "Microsoft Access" referred to in your field
"CallingForm = '" & frm(name) & "'") = CallingForm = & frmCheck
 
Last edited:
Put your criteria into a string variable then debug.print your criteria.
That usually solves silly errors. Then you can use that in the function.
Same applies to SQL strings.
 
Code:
Dim criteria As String
criteria = "CallingForm = '" & Me.Name & "'"
Debug.Print criteria
CallsID = DLookup("CBOCallsID", "tblCBOCalls", criteria)
 

Users who are viewing this thread

Back
Top Bottom