populate controls automatically

kylukru

New member
Local time
Today, 09:31
Joined
Feb 9, 2007
Messages
4
Hi there,

I am trying to populate automatically controls with city, zip, address, etc. data based on a control that contains the name of a store. I cut and paste the afterupdate event from the Norhtwind database and here is what I have:

Private Sub Name_AfterUpdate()
On Error GoTo Err_Name_AfterUpdate

Dim strFilter As String

' Evaluate filter before it's passed to DLookup function.
strFilter = "Name = " & Me!Name

' Look up product's unit price and assign it to UnitPrice control.
Me!City = DLookup("City", "StoreName", strFilter)

Exit_Name_AfterUpdate:
Exit Sub

Err_Name_AfterUpdate:
MsgBox Err.Description
Resume Exit_Name_AfterUpdate

End Sub

The error I have when I run this is:

Syntax Error (missing operator) in query expression 'Name=(Name of the store)'

Any idea of what's going on here?

Thanks,
Luke
 
Hey Luke,

Try changing this part to this:

strFilter = "Name = '" & Me!Name & "'"

If this is a text and not a number, then this should work for you.

HTH,
Shane
 
Thanks, it works perfectly!
 

Users who are viewing this thread

Back
Top Bottom