Deplicate values in combobox (1 Viewer)

sadiq92

New member
Local time
Tomorrow, 00:33
Joined
Jun 4, 2020
Messages
29
Hello



I have one table which has many fields

I created form based on Table 1 .One of the fields in form are combo box with two column (A,B) which their values come from Table 2 , Column A Are company name. Column B are Branch Number When I select from combobox , value of column A will be selected and stored in Table. I made calculated textbox which select value of Column B. The problem that sometime There are duplicate companies in column A with different branches ( Column B ). However, when I select one of the duplicate company values only the branch of first duplicate company will be selected



See the below example



2323.jpg

If I select second value ( branch 555 ) , the calculated textbox will take 123 not 55



Another example

DD.jpg


When I select Company D branch 4984 , the program will take Company D Branch 4565


Any idea how to fix this?
 

Isaac

Lifelong Learner
Local time
Today, 13:33
Joined
Mar 14, 2017
Messages
3,739
What you want to do is make the BOUND column of the combobox be the ID rather than the name. The rowsource for the combobox would be something like "select ID, name from table1" and the first column would be the bound one. At least is I understand your concern correctly.
 

sadiq92

New member
Local time
Tomorrow, 00:33
Joined
Jun 4, 2020
Messages
29
What you want to do is make the BOUND column of the combobox be the ID rather than the name. The rowsource for the combobox would be something like "select ID, name from table1" and the first column would be the bound one. At least is I understand your concern correctly.
When I make the bound column of combobox to be ID , the ID will be stored in Table. I want the name to be stored and showed in the form after selection
 

Isaac

Lifelong Learner
Local time
Today, 13:33
Joined
Mar 14, 2017
Messages
3,739
the ID will be stored in Table
...which is normally what you would want, if your tables are normalized properly.
Regardless, if you want to make any reference to a specific Column of the listbox, you can just code by referencing ComboboxName.Column(0) or ComboboxName.Column(1) to get the value in different columns
 

sadiq92

New member
Local time
Tomorrow, 00:33
Joined
Jun 4, 2020
Messages
29
...which is normally what you would want, if your tables are normalized properly.
Regardless, if you want to make any reference to a specific Column of the listbox, you can just code by referencing ComboboxName.Column(0) or ComboboxName.Column(1) to get the value in different columns

Ok
How to make the search sorting in the combobox to be by the name of the company not ID . For example if I write AA in combobox, I want the list to show me automatically the companies name which start of AA.

Also, If ID is stored in table , how to make the name to be stored as well in other field of table.
 

Isaac

Lifelong Learner
Local time
Today, 13:33
Joined
Mar 14, 2017
Messages
3,739
How to make the search sorting in the combobox to be by the name of the company not ID . For example if I write AA in combobox, I want the list to show me automatically the companies name which start of AA.

Also, If ID is stored in table , how to make the name to be stored as well in other field of table.
Well, for the sorting you would adjust your ROWSOURCE of the combobox. The rowsource is normally a table or query...which can be sorted by clicking the ellipsis button next to rowsource, and adjusting accordingly.

For storage, you can only make one column the bound column. But you could code an afterupdate event for the combobox to store Column(x) in another bound control that relates to the form's recordsource.

Again, though, if your tables are properly normalized, generally speaking, you would be storing the ID of the company in the table - NOT the name. The only place the name of the company would be stored is in a table meant to house all companies in existence. That's it..
 

sadiq92

New member
Local time
Tomorrow, 00:33
Joined
Jun 4, 2020
Messages
29
Well, for the sorting you would adjust your ROWSOURCE of the combobox. The rowsource is normally a table or query...which can be sorted by clicking the ellipsis button next to rowsource, and adjusting accordingly.

For storage, you can only make one column the bound column. But you could code an afterupdate event for the combobox to store Column(x) in another bound control that relates to the form's recordsource.

Again, though, if your tables are properly normalized, generally speaking, you would be storing the ID of the company in the table - NOT the name. The only place the name of the company would be stored is in a table meant to house all companies in existence. That's it..

can you give me the code I should wrote for storing the name in the column?
Also for you information , I need the name to be stored not the ID because in my country ( some type of companies does not have ID and I am not sure if it is effective in this case to use ID as primary key ).
Hence, what you advise me to do ( if some companies do not have ID ).

to make things clear to you,I have two forms. Each form related to its seperate table .Form 1 for company registration and form 2 for application registration.

in application registeration form ( form 2 )there is combobox which has two coloums ( ID or branch number and company name ) . This combobox list is related to form 1. Any company which is not listed in the list . I have to register it using form 1.
As I mentioed above , if company does not have ID , I keep ID field in form 1 empty and I just fill the company name field.
 
Last edited:

Users who are viewing this thread

Top Bottom