Adding to a Table list using a Form

B

Brutalius

Bear with me while I try to explain my problem:

Table 1 has two columns: CustomerColumn and CityColumn. I have created a
form which allows users to add customers to Table 1. A combo box (cmbCity)
on the form allows the user to either select a city from a drop down list
(which references a list of cities in Table 2) or to type in a new City.

On Table 1, everything works fine: the new Customer is added along with the
city, either selected from the list or newly entered.

What I can't figure out is how to add a newly entered city to the master
list of cities in Table 2. In this way, when the next customer is added,
this city will be available in the cmbCity drop down menu.

Thanks for reading.
 
M

Marshall Barton

Brutalius said:
Bear with me while I try to explain my problem:

Table 1 has two columns: CustomerColumn and CityColumn. I have created a
form which allows users to add customers to Table 1. A combo box (cmbCity)
on the form allows the user to either select a city from a drop down list
(which references a list of cities in Table 2) or to type in a new City.

On Table 1, everything works fine: the new Customer is added along with the
city, either selected from the list or newly entered.

What I can't figure out is how to add a newly entered city to the master
list of cities in Table 2. In this way, when the next customer is added,
this city will be available in the cmbCity drop down menu.


You can use cmbCity's NotInList event to add the new city:

SQL = "INSERT INTO table1 (City) VALUES(""" & NewData &
""")"
DbEngine(0)(0).Execute SQL, dbFailOnError
Response = acDataErrAdded
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top