Auto add data to drop-down list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I have a combo "Name" and a field "Address" on my form.
The combo populates from a separate table "Person" which has both "Name" and
"Address" fields, so when I pick up some name from the list, the address is
entered automatically.

Combo also allows to input new names which are not on the list.
And in this case I want the new name and the new address to be added to the
"Person" table automatically for my future use.

This is solved perfectly if I populate my combo from the same table using
"SELECT DISTINCT", but I have a reason for using a separate table.

I used to solve the problem also by manually pressing the button which runs
the following querry every time I wanted to add new record to the table
"Person":

INSERT INTO Person ( Name, Address )
SELECT T_SPENT.Name, T_SPENT.Address
FROM T_SPENT
WHERE (((T_SPENT.ID)=Forms!SPENT.ID));

This had to have a macro in addition, to refresh my records beforehand
(otherwise empty records were added).

Now I want it to run automatically on AfterUpdate Event of the Address
field, but I don't know how to write the code for this.

I want the code to check if the Name value was picked from the list or not,
and if not (which means the value is new) to add those values (Name and
Address) to the "Person" table.

Can anybody please help me??

Thank you in advance.

Lana
 
Hi, Lana.

See Douglas Steele's post below under the thread "Populate combo box as you
go".

Sprinks
 
Back
Top