More than one field results in DLookup

M

Me

Hello!

I want to fetch values of two fields using DLookup, can someone help me?

Something like DLookup("date_opened, date_closed","tablename","whereclause")

I have two separate DLookup statements working for each of the fields
date_opened=DLookup("date_opened","tablename","whereclause")
date_closed=DLookup("date_closed","tablename","whereclause")

or if there is another solution, please let me know.

Thank you,
-Me
 
B

Barry Gilbert

DLookup will only return one value. Is there some reason you need it to
return two? Your sample using two lines is the usual way to use it. If you
want to retireve two fields with one table call, you could use a recordset
object, but it seems like overkill.

Barry
 
D

Douglas J Steele

Try:

DLookup("date_opened & ',' & date_closed","tablename","whereclause")
 
K

Klatuu

aryDates = Split(DLookup("[date_opened] & Chr(124) &
[date_closed]","tablename","whereclause"), "|")

Now, aryDates(0) will contain date_opened and
arDates(1) will contain date_closed
 
K

Klatuu

You are correct that DLookup returns only one value; however, that value can
be a concatenation of values from multiple fields.
 
M

Me

Thank you Klatuu, awesome!!! It works for me.

-Me


Klatuu said:
aryDates = Split(DLookup("[date_opened] & Chr(124) &
[date_closed]","tablename","whereclause"), "|")

Now, aryDates(0) will contain date_opened and
arDates(1) will contain date_closed

Me said:
Hello!

I want to fetch values of two fields using DLookup, can someone help me?

Something like DLookup("date_opened, date_closed","tablename","whereclause")

I have two separate DLookup statements working for each of the fields
date_opened=DLookup("date_opened","tablename","whereclause")
date_closed=DLookup("date_closed","tablename","whereclause")

or if there is another solution, please let me know.

Thank you,
-Me
 
M

Me

Hi Bary,

You have a valid question, I need two, 'cause I am checking if the date is
in certain range ...

Thank you for your time!
-Me
 
M

Me

Douglas,

Thank you for taking time to answer my question, this solutions works for me.
-Me
 
Top