DLOOKUP for multiple records

M

Miranda

hi,

i've got a dlookup statement that could return multiple values, but dlookup
returns only the first matching value. is there a way to return multiple
values? any help would be appreciated

thanks,
miranda
 
T

TC

Not from DLookup.

To get one value:

dim v as variant
v = dlookup ("TheField", "TheTable", "TheWhereCondition")
debug.print v

To get multiple values:

dim db as database, rs as recordset
set db = currentdb()
set rs = db.openrecordset ("SELECT [TheField] FROM [TheTable] WHERE
TheWhereCondition")
with rs
while not .eof
debug.print ![the field]
.movenext
wend
end with

HTH,
TC
 

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


Top