Dlookup question

G

Guest

I have used Dlookup to look up items with just one criteria like the statment
below

= DLookup("PTSDDate", "Provider", "SSN = '" & Me.SSN & "'")

How do I look it up for multiple criteria
So say I wanted to know PTSD_01 for the me.SSN, me.Date, and me.visit how do
I go about adding this to the Dlookup?
 
D

Douglas J Steele

= DLookup("PTSD_01", "Provider", "SSN = '" & Me.SSN & "' And PTSDDate = " &
Format(me.Date, "\#mm\/dd\/yyyy\#"))

Note that dates are delimited with #, and should be in mm/dd/yyyy format,
regardless of what the Short Date format has been set to through Regional
Settings (although any unambiguous format, such as dd mmm yyyy or yyyy-mm-dd
will be accepted). That's the point of the somewhat cryptic parameter being
used in the Format function.

Note, too, that naming a control on your form Date isn't a good idea. Date
is a reserved word, and shouldn't be used for your own purposes.
 
F

fredg

I have used Dlookup to look up items with just one criteria like the statment
below

= DLookup("PTSDDate", "Provider", "SSN = '" & Me.SSN & "'")

How do I look it up for multiple criteria
So say I wanted to know PTSD_01 for the me.SSN, me.Date, and me.visit how do
I go about adding this to the Dlookup?

You haven't given enough information for a specific answer for which
we would need the field names as well as the field datatypes, so here
is a generic reply.
Assume Date is a Date datatype, and Visit is what? Let's say a Number
datatype.

= DLookup("PTSDDate", "Provider", "SSN = '" & Me.SSN & "' and
[DateField] = #" & Me![DateField] & "# and Me![Visit] = " &
Me![Visit])

Look up
Restrict data to a subset of records
in VBA help.
 

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

Criteria On Dlookup 1
How to pass multiple Fields to new Form 2
Dlookup error 4
DLookUp 7
dlookup with loop 1
Bound a DLookUp Value 2
DLookup help 6
using dlookup in a query 2

Top