dlookup multiple criteria

  • Thread starter Thread starter Bonnie
  • Start date Start date
B

Bonnie

Hi,

Having a little problem with syntax in a DLOOKUP

Here's what I have:

Me!CkSvcDiv = DLookup("DivZone", "MasterZips", "Zipcode = '" & Me.JobZip &
"'")

I would like to add - 'and CITY = Me.JobCity and COUNTY = Me.JobCounty.

Can anyone help?

Thanks in advance.

Bonnie
 
Try this:

Me!CkSvcDiv = DLookup("[DivZone]", "MasterZips", "Zipcode = '" & Me.JobZip &
"' And CITY ='" & Me.JobCity & "' And COUNTY = '" & Me.JobCounty & "'")

Should work!
 
Hi,

Having a little problem with syntax in a DLOOKUP

Here's what I have:

Me!CkSvcDiv = DLookup("DivZone", "MasterZips", "Zipcode = '" & Me.JobZip &
"'")

I would like to add - 'and CITY = Me.JobCity and COUNTY = Me.JobCounty.

The third argument to any of the Domain functions is a text string which
evaluates to a valid SQL WHERE clause (without the word WHERE). One handy way
to see how this should look is to create a Query in the grid which returns the
desired records, and open the query in SQL view. Find the WHERE clause and
that will give you the syntax.

In this case you have three text fields, each of which needs to be delimited
by quotemarks; since some city and county names might have apostrophes, it
would be best to use two consecutive doublequotes which will translate to a
doublequote as a delimiter:

DLookup("DivZone", "MasterZips", "Zipcode = '" & Me.JobZip & "' and CITY =
""" & Me.JobCity & """ and COUNTY = """ & Me.JobCounty & """")

This will evaluate to something like

Zipcode = '83660' and CITY = "Parma" and COUNTY = "Canyon"


John W. Vinson [MVP]
 

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

DLookUp Multiple Criteria 4
dlookup 2
Dlookup help Please !! 1
DLookUp 7
Trouble with DLookup 3
complicated query 11
Bound a DLookUp Value 2
using dlookup in a query 2

Back
Top