Ask Your Question
0

Add entries to listbox or combobox

asked 2017-11-17 21:37:50 +0200

bdphifer gravatar image

I have two tables that are related with a field on one table and the primary key on the other in a one-to-many relationship. (One table for names, other table with a field for the name) I have set up a listbox on a form with the data from the names table. Right now, I can pull a name off the list and place the ListID number in the name field, which is fine.

What I'd like to do is to be able to start to type the name in the listbox field and if the name is there, save the Primary Key number in the field; or if the name isn't there, add that name to the Names Table and save the new Primary Key number.

My questions are can I do this, if so, how, and do I use a combo or listbox?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-11-18 01:20:38 +0200

Ratslinger gravatar image

Hello,

The combo box allows entries other than what is in the list. The list box does not.

But to answer your question, what you want can be done. It does require a macro to be written. The attached sample demonstrates how.

The combo box has a list of existing name from the NAMES table. Each keystroke is checked to see if the Enter key was pressed. When the Enter key is detected, the text selected/entered is used to see if the item is in the NAMES table. If not, it is added to the table. The entry is then used to filter the main form and retrieve the selected/entered name. This then brings us the linked records in the sub-form.

Sample: ComboBoxAddRecord.odb

If this answers your question please click on the ✔ (upper left area of answer).

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-11-17 21:37:50 +0200

Seen: 824 times

Last updated: Nov 18 '17