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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting/Highlighting item In Combo Box 2

Status
Not open for further replies.

jamez05

Programmer
Jul 29, 2005
130
US
Hey, I can't figure this out for the life of me (it shouldn't be that difficult)

I created a combo box where only one value can be selected. Its Row source is a value list containing the following choices:
Unknown
Marine
Fresh
Tidal

The name of the combo box is ListClass. I have another dropdown that is a list of individual records. Each record has a field named Class that is eaither Unknown, Marine, Fresh or Tidal. I want to highlight the correct item in ListClass based on the selection from the other combo box. I've tried numerous things. How do you select an item in the combobox based off a value? Here's one of the things I've tried:

Code:
           If Me.listSitesEdit.Column(2, i) = "Marine" Then
               Me.listClass(1).Selected = True
               MsgBox "got Here2"
           End If
 
you will have to loop through all the contents of the list and test the value of each one...

e.g.

dim idx as int
for idx = 0 to listBox.listcount - 1
if listbox.itemdata(idx) = combobox then
listbox.selected(idx) = true
endif
next idx

--------------------
Procrastinate Now!
 
Why not just set the ComboBox's ControlSource property to Class?


-V
 
Thanks guys for your input. I used Crowley16's example to figure it out because I'm not sure how set the ComboBox's control source correctly:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top