automatic population of fields

  • Thread starter Thread starter Lauren B.
  • Start date Start date
L

Lauren B.

I currently have a populated table with the following fields:
1. Zip Code
2. County
3. Region

I want to set up my form so that when a user enters a zip code, the county
and region fields automatically populate with the correct information based
on the table.

What is the best way for me to accomplish this task?

Thank you in advance for any assistance.

LB
 
My approach would be something like this:

private sub TextZipCode_AfterUpdate()
dim rst as recordset
set rst = currentdb.openrecordset("MyZipCodeTable", dbOpenSnapShot)
rst.FindFirst "ZipCode = """ & TextZipCode & """"

if rst.noMatch then
msgbox "Unknown Zip Code", vbOkOnly + vbExclamation
else
textCounty = rst!County
textRegion = rst!Region
end if

rst.close
end sub

You still will need to change for the names of your table, fields and
textboxes, but It may work for you

Mauricio Silva
 
Thank you for your assistance.

For some reason, I'm not able to get this to work. I had thought that
another approach would be to create a query as the row source for the Zip
Code field. The code would then read:

P_COUNTY = Me.ZIPCODE.Column(1)
P_REGION = Me.ZIPCODE.Column(2)

This does not work either. Do you have any thoughts about using a query?

Thanks.
 
Now I need more detail. How it doesn't work? Is there a error message or it
just doesn't appear?
 
Back
Top