Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Multiple Colums in Combo Box After Selection 1

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
Is there any way to display multiple columns in a combo box after the user has made a selection rather than just displaying the first column?
 

You can only display one column. If you want the user to be able to view the data in the other columns, you can use text boxes that are filled based on the value in the combo box.

If you place them next to the combo box, you can create the illusion of displaying all columns.


Randy
 
Or, you can define the row source of the combox as:

select Field1, Field1 & '|' & Field2 & '|' & Field3
from table1

Use the column width property of the combox to hide the 1st column and show only the second column.

Seaport
 

The result of cocatenating field names and the pipe symbol in the combo box field is rather sloppy and unprofessional looking. I suggest sticking to the standard method of creating your combo box and using text boxes to display the additional fields.


Randy
 
Following Randy700, you can also show and hide controls on top of the combobox (leaving the dropdown arrow visible). When the user selects a choice, make the controls visible, then populate the data. When the user clicks on the combobox's dropdown arrow, the combobox's "Enter" event hides the controls. For example, using 2 text boxes to display the data (text539 & text540)

Private Sub Combo537_AfterUpdate()
Me.Text539.Visible = True
Me.Text540.Visible = True
Me.Text539.Value = Me.Combo537
Me.Text540.Value = "data, etc"
Me.txtFocus.SetFocus
End Sub

Private Sub Combo537_Enter()
Me.Text539.Value = ""
Me.Text540.Value = ""
Me.Text539.Visible = False
Me.Text540.Visible = False
End Sub

Note: You need to use the SetFocus to move focus to another control besides the combobox, or the "Enter" event wont trigger if the user clicks the combobox back2back
 
Just another note, I have used this type of code before on forms and it works fine. If you play around with turning off the border colors, etc, and you have the text boxes appear right on top of the combobox, it will look seamless.

If the user clicks in one of the text boxes to activate the control, then shift the focus to the combobox, hide the text boxes, and issue a drop down menu command on the combobox.
 
I am curious.

Unless I misunderstood the OP, my initial reaction is to change the column properties of the combo box to show/hide the columns. i.e.,

combobox.columncount = 4
combobox.columnwidth = 0;1;2;1

etc.

 
aperez54, yes that will work while the combobox is in dropdown status, but once the user makes a selection, then the combobox will only display the data for the "Bound Column"

If I understand the question right, after the selection is made he wants the combobox to show multiple columns of data.
 
Thanks for all your tips. Appreciate it. I will play around with the code and see what I can come up with. rustychef you understood my question exactly

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top