By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,454 Members | 2,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,454 IT Pros & Developers. It's quick & easy.

Fill multiple fields based on one entry

P: 1
Access 2000. I want to be able to enter a zip code in field one and have the related city, state and supervisor filled into field 2, 3 and 4.

Currently I add the zip code to a table, field one and then use an update query to fill in the values in field 2, 3 and 4. I use a second table with the lookup values for zip, city, state and supervisor.

I would like to update each record as I enter the zip code. Would it be best to create a form or should I create the fields in the table so they look up the correct value.
Jul 21 '07 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,597
Access 2000. I want to be able to enter a zip code in field one and have the related city, state and supervisor filled into field 2, 3 and 4.

Currently I add the zip code to a table, field one and then use an update query to fill in the values in field 2, 3 and 4. I use a second table with the lookup values for zip, city, state and supervisor.

I would like to update each record as I enter the zip code. Would it be best to create a form or should I create the fields in the table so they look up the correct value.
Assuming your Zip Code Field is Numeric, in the AfterUpdate() Event of the Zip Code Field, write code similiar to:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtZipCode_AfterUpdate()
  2. If Not IsNull(Me![txtZipCode]) Then
  3.   Me![txtCity] = DLookup("[City]", "tblLookup", "[ZipCode]=" & Me![txtZipCode])
  4.   Me![txtState] = DLookup("[State]", "tblLookup", "[ZipCode]=" & Me![txtZipCode])
  5.   Me![txtSupervisor] = DLookup("[Supervisor]", "tblLookup", "[ZipCode]=" & Me![txtZipCode])
  6. End If
  7. End Sub
Jul 21 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.