Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Criteria for DLOOKUP in IF Statement 1

Status
Not open for further replies.

dmon000

Technical User
Sep 9, 2003
79
US
Hi Everyone,

I have a table called EMAIL_DIST_LIST in which there are two fields, RECEPIENTS and LIST_NAME. I also have function FOSUSERNAME, that returns the logged on user.

I want to write an If statement that tests if the name returned by the function FOSUSERNAME is in the RECEPIENTS field when LIST_NAME = "ECN_ALL_OPERATION".

Thanks for your help!!!
 
Test to see if the returned name = DLookup("RECIPIENTS]","EMAIL_DIST_LIST","LIST_NAME = 'ECN_ALL_OPERATION'")

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Thanks for the help genomon!

My problem now is getting this to work. I think I should be using "in" instead of "=".

If fOSUserName = DLookup("RECEPIENTS", "EMAIL_DIST_LIST", "LIST_NAME = 'ECN_ALL_OPERATION'")

The Dlookup above returns 3 usernames, so the if statement will be false.

How do I write the conditional to say "If fOSUserName IS IN DLookup("RECEPIENTS", "EMAIL_DIST_LIST", "LIST_NAME = 'ECN_ALL_OPERATION'")

THANKS!!
 
You don't use DLookup if you are looking for "IN".
Another way would be to open a recordset using a WHERE clause
(filter) with the IN clause, and see if the recordcount is > 0.

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Duh (wasn't thinking). DCount() with the WHERE clause should do it. If the count > 0 (or 1, or whatever), Then ....

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top