Dlookup and Groupby problem

AnnPhil

Registered User.
Local time
Today, 08:25
Joined
Dec 18, 2001
Messages
246
I have a groupby query that i use to group by visitID and then max the Visit date so that i can have the last visit date for each customer.

I have a form that list customer information and has a DLookup field that should lookup the last visit date for each customerid. I am getting null values and i know when i run the query there is data. Anyone know why this is not working? Does it have anything to do with the fact that it is based on a groupby query? Any suggestion on a work around?

here is an example of my lookup

=DLookUp("[LastVisitDate]","[qryDateOfLastVisit]","[CustomerID]=[CustomerID]")
 
Presuming customer ID is a number, try:

=DLookUp("[LastVisitDate]","[qryDateOfLastVisit]","[CustomerID]= " & [CustomerID])
 
customerID is a text field but i tried your suggestion anyway and it returned me this #Error in the fields. :(
 
If it's a text field, try:

=DLookUp("[LastVisitDate]","[qryDateOfLastVisit]","[CustomerID]= '" & [CustomerID] & "'")
 
pbaldy said:
If it's a text field, try:

=DLookUp("[LastVisitDate]","[qryDateOfLastVisit]","[CustomerID]= '" & [CustomerID] & "'")

AnnPhil,

Try:

Code:
=DLookUp("[LastVisitDate]","qryDateOfLastVisit","[CustomerID]=[CustomerID]")
 
Try this

=DLookUp("[LastVisitDate]","[qryDateOfLastVisit]","[CustomerID]=Form.[CustomerID]")
 
pbaldy's suggestion is the correct solution. You need to enclose the string variable with quotes.
 

Users who are viewing this thread

Back
Top Bottom