Full Version: loop on listbox columns not cycling
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
rdu1968
Private Sub Command2_Click()
Dim I As Integer
Dim vItm As Variant

If Me.List0.ItemsSelected.Count > 0 Then
For Each vItm In Me!List0.ItemsSelected
Me.text1 = Me.List0.ItemData(vItm)
Me.text2 = Me.List0.Column(3)
Me.Text3 = Me.List0.Column(2)
Next vItm
Else
MsgBox "You must select at lease one Physician Name from the list."
End If
End Sub

I want to see the text1, text2, and text3 boxes change on the form as it loops thru the records... I am seeing text1 change, but not the text2 and text3 boxes. It remembers the values from the first record on text1 and just repeats that... so... value changes in 1, but remains the same in 2 and 3... Any ideas?
BrianS
Try this

Me.text2 = Me.List0.Column(3, varItm)
Me.Text3 = Me.List0.Column(2, varItm)

You must specify the row in the second argument to column otherwise it just assumes the first row in ItemsSelected.
rdu1968
Thank you that worked!!!!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.