DLookup with three criteria

F

Flora

I'm getting an MVB run-time error '3075': syntax error (missing
operator)...

This is the code I'm trying to use:

If (Not IsNull(DLookup("[PCP-SP-Ref]", "[tbl_atc_per_PCP-SP-Ref]",
_
"[PCP-SP-Ref] = '" & _
Forms!frm_TESTING_DETAILS_AND_RESULTS![PCP-SP-Ref] & _
"' AND " & "[Exception_Ref_No] = " & _
Forms!frm_TESTING_DETAILS_AND_RESULTS![Exception_Ref_No] & _
" AND [tbl_atc_per_PCP-SP-Ref].atc = 'Other.'"))) = False Then

Form_frm_TESTING_DETAILS_AND_RESULTS.Other_Action_Taken.Enabled
= False
Else
Form_frm_TESTING_DETAILS_AND_RESULTS.Other_Action_Taken.Enabled
= True
End If

I have spent hours looking at this code trying to find the problem.
Any advice?

Thanks for any help you can give.
 
T

TC

Someone else will probably spot it for you. But if not, here's the way
that I'd approach this:

Put the 3rd parameter value into a string variable, so you can print
that variable, and see exactly what you are passing. If that doesn't
show you the error, post the output here, & we are sure to see the
problem.

So, do this:

dim s as string
s = "complex where conditions"
debug.print s ' post the result!
... = dlookup (..., ..., s)

Not this:

... = dlookup (..., ..., "complex where conditions")

HTH,
TC (MVP Access)
http://tc2.atspace.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top