Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Adding to a Table list using a Form

Geek News

Adding to a Table list using a Form
Brutalius 12/30/2008 12:21:00 AM
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.


Re: Adding to a Table list using a Form
Marshall Barton <marshbarton[ at ]wowway.com> 12/30/2008 1:30:20 AM
Brutalius wrote:

[Quoted Text]
>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

--
Marsh
MVP [MS Access]

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net