Dlookup

A

Amour

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
 
R

Rick Brandt

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

"And" goes inside the quotes, not outside.
 
C

Carl Rapson

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

Should the form name be the same for both variables? You have
'frmAttendanceMeeting' in one place and 'AttendanceMeeting' in the other.

Carl Rapson
 
K

Klatuu

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.
 
A

Amour

Thank You for responding.

I followed what you said:

=DLookUp("[DateProcessed]","tblTravel","[SSN] = '" & [SSN] & "'" And
"[Meet_num] = '" & [Meet_num] & "'")

but it is not advancing to the next record. When I take out the " And
"[Meet_num] = '" & [Meet_num] & "'") it advances but I need it to check for
both SSN and Meet_num.

So what am I doing wrong

Thank You!


Klatuu said:
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
 
K

Klatuu

Can there be more than on Meet_Num for an SSN?
If so, you will have to do something a bit different. Using the code as it
is, it will always return the first match.

Perhaps what you want to do is filter the form based on the SSN and Meet_Num
and use navigation buttons to move through the matching records.
--
Dave Hargis, Microsoft Access MVP


Amour said:
Thank You for responding.

I followed what you said:

=DLookUp("[DateProcessed]","tblTravel","[SSN] = '" & [SSN] & "'" And
"[Meet_num] = '" & [Meet_num] & "'")

but it is not advancing to the next record. When I take out the " And
"[Meet_num] = '" & [Meet_num] & "'") it advances but I need it to check for
both SSN and Meet_num.

So what am I doing wrong

Thank You!


Klatuu said:
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
 
O

Ofer Cohen

=DLookUp("[DateProcessed]","tblTravel","[SSN] = '" & [SSN] & "'" And
"[Meet_num] = '" & [Meet_num] & "'")

You shouldn't cose the single quote after the (SSN) before the (And), Try

=DLookUp("[DateProcessed]","tblTravel","[SSN] = '" & [SSN] & "' And
[Meet_num] = '" & [Meet_num] & "'")

--
Good Luck
BS"D


Amour said:
Thank You for responding.

I followed what you said:

=DLookUp("[DateProcessed]","tblTravel","[SSN] = '" & [SSN] & "'" And
"[Meet_num] = '" & [Meet_num] & "'")

but it is not advancing to the next record. When I take out the " And
"[Meet_num] = '" & [Meet_num] & "'") it advances but I need it to check for
both SSN and Meet_num.

So what am I doing wrong

Thank You!


Klatuu said:
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
 

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

Not current record 0
Matching record 0
Checking for new records 0
Linking forms 2
Record control 0
Keeping current record 0
Dlookup Oject error 0
Dlookup 2

Top