I am getting a syntax error when the following executes and I can not figure
out where the problem lies. I need to NZ() BOTH birthday fields since either
or both could be null.
Well, let's parse out your quotes. It looks like they are the problem. Putting
blanks between them for readability...
If (Not IsNull(DLookup("[Last Name]", "[Twirlers]", _
"[Last Name]= ' " " & Me.[Last Name] & " " ' And [Birthday] = ' " " &
Me.[Birthday] & " " ')) Then....
I'm not sure what you were intending but you certainly won't get it! The third
argument of DLOOKUP should be a text string which evaluates to a legal SQL
WHERE clause (without the WHERE). Since lastnames may well contain apostrophes
(O'Brien for instance), it's best to use " as a string delimiter; and if
birthday is a Date/Time field you need # as a delimiter. You want the final
string to resemble
[Last Name] = "O'Brien" AND [Birthday] = #5/21/1999#
So to put it together from its components, you need to use two consecutive
doublequotes in the string constant to represent one doublequote:
"[Last Name]=""" & Me.[Last Name] & """ And [Birthday] = #" &
Me.[Birthday] & "#")) Then....
That is, you're concatenatign the pieces
[Last Name] = "
<whatever is in the Last Name control on your form>
" And [Birthday] = #
<whatever is in the birthday control>
#
If Birthday is of some other datatype, use ' instead of # for Text, and no
delimiter at all for Number.