ADawn
asked on
Hide items in a combo box
Hello (Again),
Is there any way of hiding items in the combo box. This is the code snipnet. These items are loaded into the combo box when the form loads.
s_SQL = "SELECT fld_EquipName, fld_EqManuf, fld_EqLocation, fld_EqRackNum FROM tbl_EQ_Inventory Where Len(Trim(fld_EquipName & '')) > 0 " _
& " Order By fld_EquipName ASC;"
rst.CursorLocation = adUseClient
rst.Open s_SQL, conn, adOpenKeyset, adLockOptimistic
Do While Not rst.EOF
Me.cboBoxes(1).AddItem rst("fld_EquipName").Value & " " & vbTab & " " & rst("fld_EqManuf").Value & " " & vbTab & " " & rst("fld_EqLocation").Valu e & " " & vbTab & " " & rst("fld_EqRackNum").Value
rst.MoveNext
Loop
.Close
I don't want the "fld_EqLocation" and "fld_EqRackNum" to be shown in the combo box, but I need these values to be available (placed in textboxes) when the combo box item is selected by the user.
Any ideas on how I can achieve this?
ADawn
Is there any way of hiding items in the combo box. This is the code snipnet. These items are loaded into the combo box when the form loads.
s_SQL = "SELECT fld_EquipName, fld_EqManuf, fld_EqLocation, fld_EqRackNum FROM tbl_EQ_Inventory Where Len(Trim(fld_EquipName & '')) > 0 " _
& " Order By fld_EquipName ASC;"
rst.CursorLocation = adUseClient
rst.Open s_SQL, conn, adOpenKeyset, adLockOptimistic
Do While Not rst.EOF
Me.cboBoxes(1).AddItem rst("fld_EquipName").Value
rst.MoveNext
Loop
.Close
I don't want the "fld_EqLocation" and "fld_EqRackNum" to be shown in the combo box, but I need these values to be available (placed in textboxes) when the combo box item is selected by the user.
Any ideas on how I can achieve this?
ADawn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Comboitems have a tag property, you could hid it in there!
The Tag item in the combo box can only store 1 value, not the tag value for each items in the list.
ASKER
Array worked fine.
Thanks, ADawn
Thanks, ADawn
s_SQL = "SELECT key, fld_EquipName, fld_EqManuf, fld_EqLocation, fld_EqRackNum FROM tbl_EQ_Inventory Where Len(Trim(fld_EquipName & '')) > 0 " _
& " Order By fld_EquipName ASC;"
rst.CursorLocation = adUseClient
rst.Open s_SQL, conn, adOpenKeyset, adLockOptimistic
With Me.cboBoxes(1)
Do While Not rst.EOF
.AddItem rst("fld_EquipName").Value
.ItemData(NewIndex) = rst(key)
rst.MoveNext
Loop
End with
.Close
In the cboBoxes_Click event, you can determine the key value using: cboBoxes(1).ItemData (ListIndex). Once you have the key value, you can easily get the selected record out of the rescordset to populate your text boxes.
Let me know if this helps.