question

PeterDelaney-8581 avatar image
0 Votes"
PeterDelaney-8581 asked PeterDelaney-8581 commented

I can't get the syntex right in VBA Dlookup with multiple criteria

my code is trying to lookup a record where -
the property id is a text field ;and
the financial year a number field.

initialmedian = DLookup("[prev jun median]", "FY Median", "[Property id]='" & pid & "' And [Financial Year] = FY ")

I get the error the expression you entered as a parameter produced this error: 'FY'

Appreciate any help

office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TvanStiphout avatar image
1 Vote"
TvanStiphout answered PeterDelaney-8581 commented

initialmedian = DLookup("[prev jun median]", "FY Median", "[Property id]='" & pid & "' And [Financial Year] = " & FY)
Do you see it now? You're just concatenating substrings.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Brillaint - it worked and yes thank you for the perspective I get it.

0 Votes 0 ·