Combo box to make adding new customers easier

Hello there! I am still thinking of making a combo box to make adding new customers easier. For example in the Invoice form (attached odb file), I made there a company name combo box (Comp_Name_ComboBox).

What I want is:

  1. When the entry is not in the combo box list, let it trigger a „When losing focus“ event to insert the entry to the CompanyName field of the Customers table;
  2. After that let the Customers form be opened where the CompanyName = the above entry;
  3. Let the user continue adding the remaining Address and PhoneNumber fields in the Customers form before closing it.
  4. The user will then continue entering the data in the Invoice form.

Because customers can be many, and the user does not necessarily know who is new customer who is not, I think it will be nice if the combo box with a macro can check if the customer’s name is in the list or not.

Does it make any sense? Is it useful? How feasible is it with Base? What do you think? I have just started to learn Base these days. I hope someone here can help. Any insight will be highly appreciated! :pray: :pray: :pray:
odb74-Invoice-pt2-Forms-2.odb (22.0 KB)

Hello,

Don’t see why it could not be done (would not use my time on this) but also don’t see why one would want this.

You have not presented much in the way of “What If’s”. Such as What if L vs l is entered in a name (and all its’ variations)? What if there are two companies with the same name? Who is going to maintain the mess created in the Company table? Likely there is more to be concerned about. For example, they enter a new because it isn’t in the list. After completing the new and return to the first form they realize it is a spelling error and it was in the list already. Now there are more issues.

Best to use a list box and forget the combo auto entry. This most likely would cost more time than it could save.

2 Likes

Hi and thank you! My goodness! I really didn’t realise these ifs! But you are right. That can cause lots of problems.

Maybe pop up a warning msg box before inserting saying: “selected Text” will be inserted to the table xy, pls check again it’s spelling! (User has to check and confirm with Yes or No button, can eliminate some of the problems?

The reason I think Combo Box is better than List Box in this case is one can type new entry in combo box to trigger an event to check if the entry is already in the list or not. With list box there is No possibility to type anything. One can only select, and go with the check manually. Namely to check in the list box if the entry exits or not, if not The user has to open An adding new customer form to find finish adding the new entry. That will take some time.

But I didn’t realise that there are companies with the same name. Frankly I don’t know how to deal with that problem (But that will be a problem even with the list box) and that’s the reason we beginners are here.

So I still hope someone can help. At least let the discussion flow. :pray:

Actually can be done in a list box by displaying the Co name and say city. So this can also be done in a combo box. However, with a list box you can store values other than the text displayed like the ID thus saving valuable space and data repetition. With a combo box, more macros?

1 Like

Actually can be done in a list box by displaying the Co name and say city. So this can also be done in a combo box. However, with a list box you can store values other than the text displayed like the ID thus saving valuable space and data repetition. With a combo box, more macros?

Yeah Co name + city! Super idea! :+1::+1::+1:

I don’t understand “with a list box you can store values other than the text displayed like the ID thus saving valuable space and data repetition. ” but I know that you are a much higher level ( respect! )

It’s one of the differences to the combo box. It allows you to display one thing and store a different value to refer to it. For example both controls can display:

Select COMPANY from COTABLE

But in a list box you can do this:

Select COMPANY, ID from COTABLE

and with an additional setting, display the first field & store the second field in the table record. When retrieved with the list box, the ID will retrieve & display the proper name.

1 Like

Have a look at the Base Guide. There is shown a macro to save values from a combobox like you want it. Data of the combobox will be saved, if data where new.

… and there is also a dialog, which will remove all entries, which aren’t needed any more, because you have written a “Company” in a new way and see you have saved the “Company” with another name.

The combobox won’t be used for save the values, which are shown in the box. It will work like a listbox, because the foreignkey will be created by query or, if there is a new text in the combobox, by inserting new value and reading the new primarykey for this value.

Could be the macro in the English Base Guide has been changed in the original German Base Handbuch. The German documentation contain more examples, which will work with this kind of macro.

2 Likes

Wow that’s good news! I didn’t know that! I will check it up. Thank you :pray:

Thank you Robert so much! This is purely fantastic.
The file is called Example_Combobox_Listfield.odb, I downloaded it from https://wiki.documentfoundation.org/images/5/52/Sample-databases.zip

I was totally astonished by what Base is capable to do. There are two combo boxes in the form, the 1st one “com_street” is a simple one (source is Sql: SELECT “street” FROM “street” ORDER BY “street” ASC), but the 2nd one “com_postcode” is much more complicated, containing two parts: postcode and the town name. In the macro, there is the procedure of spliting of this content and inserted respectively into the table where they belong.
First time saw a hidden control (combofields), inside the Additional information, there are the names of the above two combo boxes! Awesome design. I have a feeling that MS Access is a little more user friendly, but Base can be super powerful (if one knows how to use Macro). Will have to study the Comboboxes Macro attached to the event, in order to use it. That’s a joyful discovery, Robert, thank you once again. :pray: :pray: :pray: