Dlookup Or My Stupidity ???

CharlesWilliams

Registered User.
Local time
Today, 09:07
Joined
Dec 7, 2004
Messages
70
Hello Everyone,

Someone must have put a stupid pill in my coffee this morning. :eek:

Here's the problem. I put the zip code in and it is suppose to autofill the city and state but it doesn't work. :mad:

Can someone look at the attached file and tell me what I might be doing wrong? I've look at this over and over again and just don't see what I might be doing wrong. :o
 

Attachments

Hi Charles,

The next time just post you code right with the message instead of a picture of it. We can't cut and paste from a picture. Your [ZipCode] field is almost certainly a text field and you have coded for a numeric field. Try:
Code:
Me.HomeCity  = DLookup("[City]","tblzipcodes","[ZipCode]='" & Me.HomeZip & "'"
Me.HomeState = DLookup("[State]","tblzipcodes","[ZipCode]='" & Me.HomeZip & "'"
.Value is the default property so you do not really have to spell it out.
 
Thank you very much for you response. I'll try it out in a little bit. Also I'll keep in mind about posting my code.

- Charles

P.S.

Here's the code...

Private Sub HomeZip_AfterUpdate()

Me.HomeCity = DLookup("[City]", "tblzipcodes", "[Zipcode]=" && Me.HomeZip.Value)
Me.HomeState = DLookup("[State]", "tblzipcodes", "[Zipcode]=" && Me.HomeZip.Value)

End Sub
 
DLookup Or My Stupidity ???

Next Problem:

After I put it in the form and got it to work they told me that we are going to have a problem with multiple cities having the same zip code. (Now They Tell Me !!!). Can't I Make it so when the zip code is filled in the city box (ComboBox) drops down with a list of cities that have that zip code ???

Thanks for all your help.

- Charles
 
You can base your CityComboBox on a Row Source that has your HomeZip control as part of the where clause and requery the CityComboBox in the AfterUpdate event of the HomeZip control.
 

Users who are viewing this thread

Back
Top Bottom