Multi Column Combo Box

JessicaGomo

Registered User.
Local time
Today, 08:54
Joined
Feb 26, 2015
Messages
21
I have a multiple column combo box on my form, that is correctly populating. When I make a selection, it displays the result from the first column. Bound column seems correct, as my table is being populated correctly.

1 - Can I display the values from both columns after the selection has been made?

2 - If not, can I choose to display the second column (not the first) after the user has made a selection?

Thanks in advance.
 
You can create a text box, say Text1, right next to the combo box.
Create a combo box AfterUpdate event and write

Private Sub myCombo_AfterUpdate()
Text1 = myCombo.Columns(1)
End Sub

If a combo box has multiple fields (columns), they are referred to as myCombo.Columns(0), myCombo.Columns(1), etc. myCombo is the same as myCombo.Columns(0).

This way, myCombo's first column value will stay in the combo box and the second column value will appear at Text1.

Shoji
 
Thank you! One thing to note is the code is .column, not .columns (for any future users of this thread).

I am still having one issue as I am doing this on a continuous form. ALL of the textboxes hold the value of the most recently selected item, not the one that was populated at time of entry. HELP!!
 
Great.

Judging from your description, I gather that this continuous form is a sub form. In that case, when the main form is populated, you add this line at some appropriate place:

Me.<sub form name>.Requery

Now where this line should be placed is dependent on how you populate the main form. If you choose some ID, then create an AfterUpdate event and write

Private Sub ID_AfterUpdate()
Me.<sub form name>.Requery

Anyway, study Requery and you can find the right answer.
By the way, if this is a sub form, you set the Master-Child keys?

Shoji
 

Users who are viewing this thread

Back
Top Bottom