Add entries to listbox or combobox

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?

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 :heavy_check_mark: (upper left area of answer).

@Ratslinger,

Please do not reply.

It is important for me that you know that this helped me help my grandson. 15109643309379802.odb is on his machine since May 2019.

Thank you.