Question Regarding Combobox (1 Viewer)

blckpnk01

New member
Local time
Today, 08:00
Joined
Mar 31, 2020
Messages
4
I have a form with a combobox and a text box.
The combobox contains data from a query.
When selecting data in the combo box, the details will be displayed in the text box.
For example the data in the combobox are [A, B, C, D .......] and i selected the letter A and it was displayed in the text box.
When i am selecting random letters in the combobox, the details was displayed in the textbox however, the letter displayed in the combo box is not the letter i have selected. I choose C it was displayed in the text box but in the combo box the letter displayed is random letter not C.

How to fix this?? Thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:00
Joined
May 7, 2009
Messages
19,246
depends on how you Set the value of your textbox.
you can use the textbox ControlSource property =[combobox]
or you can add code to the AfterUpdate event of your combo:

private sub combo_afterupdate()
me.textbox = [combo]
end sub

also make sure that you Refer to correct column number of the combo.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 01:00
Joined
Jul 9, 2003
Messages
16,369
Have a look at the tip on my Nifty Tips page, the Tip titled "Display Data from a Combo Box in a text box"

Here:-
 

blckpnk01

New member
Local time
Today, 08:00
Joined
Mar 31, 2020
Messages
4
depends on how you Set the value of your textbox.
you can use the textbox ControlSource property =[combobox]
or you can add code to the AfterUpdate event of your combo:

private sub combo_afterupdate()
me.textbox = [combo]
end sub

also make sure that you Refer to correct column number of the combo.

Hello sir. Thanks for your reply

The selected value from the textbox is displaying properly. My only problem is that the value displaying is not match with the data that i selected and displayed in the textbox.

For example, i choose A. In the text box the value is A, but in the combobox, the value is B

Let me know if i explain it clearly since im not confident with my english. Thank you
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:00
Joined
May 7, 2009
Messages
19,246
in design view of your form, check How many columns are there in the combobox.
determine which columns you need to display on the textbox (remember column number for comboboxes are zero based,
meaning you refer to Column 1 as Column(0).

which one is the dependent control, the textbox or the combo?
 

blckpnk01

New member
Local time
Today, 08:00
Joined
Mar 31, 2020
Messages
4
in design view of your form, check How many columns are there in the combobox.
determine which columns you need to display on the textbox (remember column number for comboboxes are zero based,
meaning you refer to Column 1 as Column(0).
Hello sir,

There are 9 columns in my combo box and the details that was displayed in the textbox is correct. Problem is that after i choose A, the value in the combobox is different. May i ask if there's a way to match them?

1585645432315.png
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:00
Joined
May 7, 2009
Messages
19,246
so the combo has the problem?
check and run the source query of the combobox, how many column do you see?
go back to your combobox in design view.
put on its Column Count property the number of column you see in query.
on it's Column Widths property put the width (in) of each column separated by semicolon.
putting 0 on a column will hide that column.
 

blckpnk01

New member
Local time
Today, 08:00
Joined
Mar 31, 2020
Messages
4
so the combo has the problem?
check and run the source query of the combobox, how many column do you see?
go back to your combobox in design view.
put on its Column Count property the number of column you see in query.
on it's Column Widths property put the width (in) of each column separated by semicolon.
putting 0 on a column will hide that column.

Hello Sir,

Yes the combobox has the problem. The display value in the combox is not consistent. Sometimes, its matched to the value that i selected and displayed in the combo box but sometimes its a different value.

I have also change the width of the other column to make the combo only shows 1 column.

I have also added a code comboboc.default value = """" & me!combobox & """" to check if changing the default valuw will resolve this but it still not working
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:00
Joined
May 7, 2009
Messages
19,246
can you post a .zip copy of your db (remove sensitive data and put some sample one).
 

Users who are viewing this thread

Top Bottom