DLOOKUP for multiple records

  • Thread starter Thread starter Miranda
  • Start date Start date
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
 
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
 
Back
Top