Dlookup Problem

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

In one of my tables I have a field called TapCo. It is a yes/no field and it
is checked for true. I also have another field called email.

What I'm trying to do is to find the email based on the yes/no field being
true. Here is the code.

Email = Nz(DLookup("EMail", "tblSupervisor", TapCo = True))

It never finds the record. when I debug it and hover over the Email it just
shows Email"". What am I doing wrong?

Thanks for taking the time to read this.
 
M

Michel Walsh

All the arguments must be literal:


Email = Nz(DLookup("EMail", "tblSupervisor", "TapCo = True"))


should do, or simply:


Email = Nz(DLookup("EMail", "tblSupervisor", "TapCo"))




That will return the first record it finds where TapCo is checked (or set
to true, which is the same, just a different "format" to present the data).



Vanderghast, Access MVP
 
F

fredg

In one of my tables I have a field called TapCo. It is a yes/no field and it
is checked for true. I also have another field called email.

What I'm trying to do is to find the email based on the yes/no field being
true. Here is the code.

Email = Nz(DLookup("EMail", "tblSupervisor", TapCo = True))

It never finds the record. when I debug it and hover over the Email it just
shows Email"". What am I doing wrong?

Thanks for taking the time to read this.

Each of the arguments in the DLookUp must be strings. Your where
clause argument is not a string.

Of what use is the Nz() function in this instance?

Email = DLookup("EMail", "tblSupervisor", "TapCo = True")

In VBA help look up
DLookUp
and also
Restrict data to a subset of records
to learn how to write a where clause using different datatype fields.
 
A

Afrosheen via AccessMonster.com

Thanks for both replies. I did get it to work with your suggestions.


In one of my tables I have a field called TapCo. It is a yes/no field and it
is checked for true. I also have another field called email.
[quoted text clipped - 8 lines]
Thanks for taking the time to read this.

Each of the arguments in the DLookUp must be strings. Your where
clause argument is not a string.

Of what use is the Nz() function in this instance?

Email = DLookup("EMail", "tblSupervisor", "TapCo = True")

In VBA help look up
DLookUp
and also
Restrict data to a subset of records
to learn how to write a where clause using different datatype fields.
 

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

Top