PSUIVERSON
Technical User
I am populating a list box with roughly 35,000 records. I put in a search functionality that looks for the account number and highlights it for the user.
However, when it hits record i value 32,768 in the list index it gives me an overflow error.
Is the list box index limited to the integer range?
Here is my code: I bolded where I get the <Overflow> error:
Private Sub cmdSearch_Click()
Dim searchText As String
Dim adoConnection As ADODB.Connection
Dim rst As ADODB.Recordset
Dim connectString As String
' Create a new connection
Set adoConnection = New ADODB.Connection
' Creat a new Recordset
Set rst = New ADODB.Recordset
' Build connection string
connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=L:\SOM Files\FINSYS WORK\SOMM_ConversionProcess.mdb"
adoConnection.Open connectString
' Populate Values into List Box
rst.Open "Finsys_Populate", adoConnection, adOpenKeyset, adLockReadOnly
searchText = Left(mskSearch.Text, 3) & Right(mskSearch.Text, 4)
rst.MoveFirst
Do While Not rst.EOF
If rst!area & rst!orgn = searchText Then
GoTo keepGoing
End If
rst.MoveNext
Loop
MsgBox ("Please enter valid search criteria. Entry not found."
Exit Sub
keepGoing:
' Overflow ERROR --> Think List box Index maxes out
For i = 1 To 50000
If searchText = Left(lstAcct.List(i), 7) Then
lstAcct.Selected(i) = True
GoTo FoundExit
End If
Next i
MsgBox ("Your selection was not found. Please reenter and search again."
FoundExit:
End Sub
However, when it hits record i value 32,768 in the list index it gives me an overflow error.
Is the list box index limited to the integer range?
Here is my code: I bolded where I get the <Overflow> error:
Private Sub cmdSearch_Click()
Dim searchText As String
Dim adoConnection As ADODB.Connection
Dim rst As ADODB.Recordset
Dim connectString As String
' Create a new connection
Set adoConnection = New ADODB.Connection
' Creat a new Recordset
Set rst = New ADODB.Recordset
' Build connection string
connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=L:\SOM Files\FINSYS WORK\SOMM_ConversionProcess.mdb"
adoConnection.Open connectString
' Populate Values into List Box
rst.Open "Finsys_Populate", adoConnection, adOpenKeyset, adLockReadOnly
searchText = Left(mskSearch.Text, 3) & Right(mskSearch.Text, 4)
rst.MoveFirst
Do While Not rst.EOF
If rst!area & rst!orgn = searchText Then
GoTo keepGoing
End If
rst.MoveNext
Loop
MsgBox ("Please enter valid search criteria. Entry not found."
Exit Sub
keepGoing:
' Overflow ERROR --> Think List box Index maxes out
For i = 1 To 50000
If searchText = Left(lstAcct.List(i), 7) Then
lstAcct.Selected(i) = True
GoTo FoundExit
End If
Next i
MsgBox ("Your selection was not found. Please reenter and search again."
FoundExit:
End Sub