Using Dlookup in Access XP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro, using the SendObject action. I want to use the Dlookup function to look up email addresses in a table and place them in the "To:" and "CC:" boxes of the email automatically. I have tried using the Dlookup function and it seems to work only for one address in each box. Can I use Dlookup to lookup multiple entries in a table.

Here is what I have been using in the "To:" argument of the SendObject action...
=DLookUp("[strPrimEmail]","[tdvSafetyCoordinator]"," [tdvSafetyCoordinator]![strCompany]=[strOPCO]")

I would also like to have the above function lookup [strSecEmail] field entry. Can I do that?

Thanks.
 
DLookup will return the value from the indicated field that is in the first
record that DLookup finds that matches the criterion expression that you
specify. It will not return values from all records that match the
criterion.

DLookup can return calculated values (such as "[strPrimEmail] & "" "" &
[strSecEmail]" as the returned value), but you cannot have it return values
from multiple fields as individual values.

--

Ken Snell
<MS ACCESS MVP>

Dashman said:
I have a macro, using the SendObject action. I want to use the Dlookup
function to look up email addresses in a table and place them in the "To:"
and "CC:" boxes of the email automatically. I have tried using the Dlookup
function and it seems to work only for one address in each box. Can I use
Dlookup to lookup multiple entries in a table.
Here is what I have been using in the "To:" argument of the SendObject action...
=DLookUp("[strPrimEmail]","[tdvSafetyCoordinator]","
[tdvSafetyCoordinator]![strCompany]=[strOPCO]")

I would also like to have the above function lookup [strSecEmail] field entry. Can I do that?

Thanks.
 
Thanks for the tip. Although I wasn't able to combine these 2 values with a semi-colon between with the same Dlookup formula. I was able to create a query that combined the two values together with a semi-colon and then use the Dlookup in my macro to lookup the combined value with the semi-colon between them for the automatic email. Your tip helped me find a solution to a problem I have been dealing with for weeks.

Ken Snell said:
DLookup will return the value from the indicated field that is in the first
record that DLookup finds that matches the criterion expression that you
specify. It will not return values from all records that match the
criterion.

DLookup can return calculated values (such as "[strPrimEmail] & "" "" &
[strSecEmail]" as the returned value), but you cannot have it return values
from multiple fields as individual values.

--

Ken Snell
<MS ACCESS MVP>

Dashman said:
I have a macro, using the SendObject action. I want to use the Dlookup
function to look up email addresses in a table and place them in the "To:"
and "CC:" boxes of the email automatically. I have tried using the Dlookup
function and it seems to work only for one address in each box. Can I use
Dlookup to lookup multiple entries in a table.
Here is what I have been using in the "To:" argument of the SendObject action...
=DLookUp("[strPrimEmail]","[tdvSafetyCoordinator]","
[tdvSafetyCoordinator]![strCompany]=[strOPCO]")

I would also like to have the above function lookup [strSecEmail] field entry. Can I do that?

Thanks.
 
You're welcome. Good luck.
Dashman said:
Thanks for the tip. Although I wasn't able to combine these 2 values with
a semi-colon between with the same Dlookup formula. I was able to create a
query that combined the two values together with a semi-colon and then use
the Dlookup in my macro to lookup the combined value with the semi-colon
between them for the automatic email. Your tip helped me find a solution to
a problem I have been dealing with for weeks.
 
Back
Top