Dlookup and Groupby problem (1 Viewer)

AnnPhil

Registered User.
Local time
Today, 09:45
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]")
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:45
Joined
Aug 30, 2003
Messages
36,133
Presuming customer ID is a number, try:

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

AnnPhil

Registered User.
Local time
Today, 09:45
Joined
Dec 18, 2001
Messages
246
customerID is a text field but i tried your suggestion anyway and it returned me this #Error in the fields. :(
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:45
Joined
Aug 30, 2003
Messages
36,133
If it's a text field, try:

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

R6Flyer

Yamaha hooligan
Local time
Today, 09:45
Joined
Nov 21, 2003
Messages
95
pbaldy said:
If it's a text field, try:

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

AnnPhil,

Try:

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

GrahamB

Registered User.
Local time
Today, 09:45
Joined
Aug 13, 2003
Messages
22
Try this

=DLookUp("[LastVisitDate]","[qryDateOfLastVisit]","[CustomerID]=Form.[CustomerID]")
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:45
Joined
Feb 19, 2002
Messages
43,478
pbaldy's suggestion is the correct solution. You need to enclose the string variable with quotes.
 

Users who are viewing this thread

Top Bottom