I have a query that populates a form on load:
My subform can have multiple records so there is a navigation bar at the bottom. I'm using the oncurrent to try and highlight the listbox option values based on the record. The problem is that I can navigate through the first one or two records, then it blows up and errors. It has something to do with the select box. When I comment the part out about "Me.lstClass.Selected(i) = True" , it works. When I uncomment it, it blows up:
Code:
'Populate Class List box
Dim strSQL As String
strSQL = "SELECT DISTINCT Class from tblChemClass ORDER BY Class"
Form![UpdateChemClass]![UpdateChemClassSub]![lstClass].ColumnCount = 1
Form![UpdateChemClass]![UpdateChemClassSub]![lstClass].ColumnHeads = False
Form![UpdateChemClass]![UpdateChemClassSub]![lstClass].RowSourceType = "table/query"
Form![UpdateChemClass]![UpdateChemClassSub]![lstClass].RowSource = strSQL
My subform can have multiple records so there is a navigation bar at the bottom. I'm using the oncurrent to try and highlight the listbox option values based on the record. The problem is that I can navigate through the first one or two records, then it blows up and errors. It has something to do with the select box. When I comment the part out about "Me.lstClass.Selected(i) = True" , it works. When I uncomment it, it blows up:
Code:
For i = 0 To Me.lstClass.ListCount - 1 Step 1
If Me.lstClass.ItemData(i) = Me.TxtClass.Value Then
Me.lstClass.Selected(i) = True - comment this out and it works fine?
End If
Next i