Where are you trying to use this code? If a DLookup is used in a VBA
procedure, the error you would expect would be Error 2001 - You Canceled the
Previous Operation. That is because one of the names used in the code does
not exist. What happens is the code is sent to Jet, but since the name
doesn't exist, Jet doesn't know what to do with it, cancels the operation and
passes the error back to Access.
Usually when you see the #Name error, you are probably using this in the
control source of a form control. You don't say if the form identified in
the code is the form the code is in. If it is a different form, that form
must be open. If it is the current form, drop the reference to the form, and
use only the control name.
=DLookUp("[DateProcessed]","tblTravel","[SSN] = '" & [SSN] & "'" And
"[Meet_num] = '" & [Meet_num] & "'")
BTW, Access does automattically name controls the same name as the control
source field, but this is a very bad habit. I would suggest using some
standard naming conventions. Searching MSDN for "Naming Conventions" will
help.
For example if the field name is [SSN] and the control is a text box, it
should be txtSSN, txtNeetNum, etc.
--
Dave Hargis, Microsoft Access MVP
Amour said:
I'm still in the very early learning stage with Access. I'm trying to
use the DLookup feature using the following code:
=DLookUp("[DateProcessed]","tblTravel","[SSN] = '" &
[Forms]![frmAttendanceMeeting]![SSN] & "'" And "[Meet_num] = '" &
[Forms]![AttendanceMeeting]![Meet_num] & "'")
but I get #Name# Error
Please help thank you