set value based on another field value

AnnPhil

Registered User.
Local time
Today, 12:12
Joined
Dec 18, 2001
Messages
246
I know i have done this before but my mind is drawing a blank....

I have two fields, City and State; i would like the State to automaticly fill in after the city is selected from a combo box.

I tried the set value in a macro and in code in the After update event of the City field, but nothing happens, not even an error message. Maybe i am looking at this all wrong, does anyone have any suggestions on how to do this painlessly.

Thanks in advance.
 
AnnPhil,

How do you know what state to fill in?

Your approach sounds OK, but need more detail.

Wayne
 
I have a City/States table and i have an Address table. When a user selects a City in the form the user then fills in the State field. I would like to automate the State information so i tried to add the following code in the "after update" event of the city field.

set value.state=DLookup("[State]","City","[City]=Forms!Addresses!City")

I dont know why this doesn't work, can you help?
 
AnnPhil,

You're close ...

Code:
Me.State =DLookup("[State]","City","[City]='" & Forms!Addresses!City & "'"

hth,
Wayne
 
Thanks for replying back so fast! It works great!
 
Or include the state in the combo box as a hidden second column then..

State=ComboName.Column(1)
 

Users who are viewing this thread

Back
Top Bottom