I have inherited a Excel workbook which has a listbox populated by a query on a database table. Recently the number of records returned has exceeded 60. The following code is used to red the selected items.
For i = 0 To LBSubjects.ListCount - 1
If LBSubjects.Selected(i) Then
keystr = keystr & LBSubjects.List(i, 0) & ","
End If
Next
Unfortunately this only goes as far as the 60th record and then exits the loop.
The ListCount appears to be a fixed at a maximum of 60 and is readonly property.
Does anyone have a method of reading through all the records?
Code for loading data to listbox
For Each ENode In XResp.documentElement.selectSingleNode("SUBJECT").childNodes
AddItemToList LB, Array(ENode.selectSingleNode("SUBJECTID").Text, ENode.selectSingleNode("SUBJECTNAME").Text)
Next
Public Function AddItemToList(InList As MSForms.ListBox, inArray As Variant)
Dim j As Integer
InList.AddItem (inArray(0))
For j = 1 To UBound(inArray)
InList.List(InList.ListCount - 1, j) = inArray(j)
Next
End Function
The listbox is an item in a sheet and not in a user form
Many thanks
Sandy
Sandy
For i = 0 To LBSubjects.ListCount - 1
If LBSubjects.Selected(i) Then
keystr = keystr & LBSubjects.List(i, 0) & ","
End If
Next
Unfortunately this only goes as far as the 60th record and then exits the loop.
The ListCount appears to be a fixed at a maximum of 60 and is readonly property.
Does anyone have a method of reading through all the records?
Code for loading data to listbox
For Each ENode In XResp.documentElement.selectSingleNode("SUBJECT").childNodes
AddItemToList LB, Array(ENode.selectSingleNode("SUBJECTID").Text, ENode.selectSingleNode("SUBJECTNAME").Text)
Next
Public Function AddItemToList(InList As MSForms.ListBox, inArray As Variant)
Dim j As Integer
InList.AddItem (inArray(0))
For j = 1 To UBound(inArray)
InList.List(InList.ListCount - 1, j) = inArray(j)
Next
End Function
The listbox is an item in a sheet and not in a user form
Many thanks
Sandy
Sandy