Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need suggestion to handle postal codes

Status
Not open for further replies.

Aydan

Technical User
Dec 14, 2002
51
0
0
BE
The contacts in my database are 99% of the cases all residing in the same country. I have my postal codes from this country all in a table. In the contacts form, I want to create a combo box for the postal codes where the user can choose from so it will lookup the corresponding City and put it into the field 'City'. BUT, rarely I have a contact from another country (i can't collect all the postal codes from all different counties).i was thinking to create another postal codes table for the foreig contacts.
But how to catch this up in my combo box in the contacts form? And what kind of primary key should I use in the contacts table (was first thinking to use the postal code as a primary key or should I best use autonumber field)?
Thanks,
A.
 
I wouldn't create a new table just for foreign contacts. I'd create a tblPostal with PostalCode as the primary key, along with City and Country. I'd create a combo box with the wizard that pulls up all three fields, but sorted by Postal Code. Then I'd put a few text fields, txtCity and txtCountry. Then on the cboPostal change event I'd run this code. Whenever you change the combo box the text fields automatically fill.

Private Sub cboPostal_Change()
txtCity = cboPostal.Column(1)
txtCountry = cboPostal.Column(2)
End Sub
 
You mean no autonumber field in the tblpostal as primary key but set postalcode as the primary key. In the form, set one combobox with 3 colums. And in the case of a foreign contact,where the postal code is not in the list of postal codes, you'd use the not in list property to add a new record?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top