Dlookup question

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
= 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.
 
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.
 
Back
Top