DLookup with three criteria

  • Thread starter Thread starter Flora
  • Start date Start date
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.
 
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
 
Back
Top