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!

Moving to next Item selected in a List Box 1

Status
Not open for further replies.

pdldavis

Technical User
Oct 29, 2001
522
US
Hi, I am trying to obtain the values of items selected in a list box for the purpose of building a string.

I can get the count of Items selected and loop through the count but I can't move to the next item selected to obtain the next value.

This is what I have so far:
Dim frmCnt, frmListCount As Long
Dim frmType As String


'Obtain the value of each item selected in the list box.

With Me.lstForms

For frmCnt = 0 To frmListCount - 1

If .Selected(frmCnt) Then

frmType = Me.lstForms.Column(0)
'need to move to the next frmType

End If


Next frmCnt


End With


frmType = Me.lstForms.Column(0) - is the problem. It picks up the first row in the list box but I don't know how to pick up the next item(s) selected.

Any help would be appreciated.

Thanks, Dan
 
Hi Dan!

Me.lstForms.Column(0, frmCnt)

A better way is like this:

Dim varRow as Variant
Dim strVar as String

For Each varRow In Me.lstForms.ItemsSelected
strVar = strVar & Me.lstForms.Column(0, varRow) & ";"
Next varRow

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Thank you, Jeff!

Saved me tons of time and I appreciate it.

Thanks again, Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top