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

How to select an Item in a list box programatically

Status
Not open for further replies.

pcdaveh

Technical User
Sep 26, 2000
213
US
Situation:

I have a form with Two list boxes. When I select an item in list box one I want to programatically select its duplicate in listbox two if there is "unique" finding one or more instances of the same item. if not I want to send a message to the screen.
 
Hi!

In the after update event procedure you can try the following:

Dim intRow As Integer
Dim intCount As Integer

intCount = 0
For intRow = 0 To ListBoxTwo.ListCount - 1
If ListBoxTwo.Columns(0, intRow) = ListBoxOne.Value Then
ListBoxTwo.Selected(intRow) = True
intCount = intCount + 1
End If
Next intRow

If intCount = 0 Then
Call MsgBox("There were no matching items in List Box 2")
End If

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thanks Jeff that worked beautifully!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top