Kinda confused.... :(

donbettis

Old User Gone Astray
Local time
Today, 08:59
Joined
Jan 23, 2001
Messages
103
Here's my confusion...

I have a form which contains 6 zipcode fields (ie... Zip, PrevZip, EmployerZip, CoZip, CoPrevZip, CoEmployerZip) I can use the code below on one field and it works great...However I can not get it to work on more then one field in the same table... I have even tried making multi zipcode tables... I've changed different things around... I am lost...


Thx in advance...

Don


Private Sub Zip_BeforeUpdate(Cancel As Integer)

City = DLookup("[City]", "tblCounty", "[Zip]= '" & Me!Zip & "'")
State = DLookup("[State]", "tblCounty", "[Zip]= '" & Me!Zip & "'")

End Sub
 
I'm not sure what you are looking to get. If you are trying to return the results of 2 or more fields with a single DLookUp, create a query with the fields concatenated into one field (i.e. "[city] & ", " & [state] & " " & [zip]) and perform the DLookUp on the query.
 
I'm curious as to why you have this in the BeforeUpdate event. Don't you want to run this code after the user has entered a new zip? Or are you trying to fill in the city and state when the form opens?
 
shacket

Yes I am trying to return the results of 2 fields and, Believe it or not but this works... I tried using a query to do this... I couldn't get it to work... I am learning new stuff everyday...
smile.gif



Chris RR

"Curious as to why this is in the BeforeUpdate Event" Well to be truthful... I hadn't really thought about it... About 6 months ago someone sent me an example that worked, So I guess I never questioned it...

And yes I want it to update after a new zipcode has been entered...

Putting the info in the AfterUpdate Event fixed my problem...

Confused NoMore... Well not about this anyways...


Thanks to You Both...
 

Users who are viewing this thread

Back
Top Bottom