-
dlookup multiple fields -'Run-time error '13'
Hi,
I know that a lot about Dlookup has been written, but I struggle to compile a code with two criteria.
Example, these two codes work separately just fine.
DebitF = DLookup("Credit", "qryGeneralLedger", "CustCodeF = " & CustCode)
DebitF = DLookup("Credit", "qryGeneralLedger", "ReferF = '" & Refer & "' ")
However I want to put both two criteria in once code something like the one shown below with reported Error 'Run-time error '13':
DebitF = DLookup("Credit", "qryGeneralLedger", "CustCodeF = " & CustCode And "ReferF = '" & Refer & "' ")
Just to add note:
Cust code is Numeric value
Refer is text value
Thanks in advance for help!
-
I got this figured out. If anyone is interested in how I solved this:
First, I changed the order for the individual codes. The order in the creiteria is very important!
This is the correct code for both individually:
DebitF = DLookup ("Credit", "qryGeneralLedger", "CustCode =" & CustCodeF)
DebitF = DLookup ("Credit", "qrygeneralLedger", "Refer = '" & ReferF & "'")
And this is then one code that considers both conditions together:
DebitF = DLookup ("Credit", "qryGeneralLedger", "CustCode =" & CustCodeF & "AND Refer = '" & ReferF & "'")
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules