View Full Version : Kinda confused.... :(


donbettis
11-08-2001, 12:37 PM
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

shacket
11-09-2001, 06:22 AM
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.

Chris RR
11-09-2001, 06:25 AM
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?

donbettis
11-09-2001, 07:43 AM
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... http://www.access-programmers.co.uk/ubb/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...