S
Steven
I have a form with a TextBox and a ListBox. The ListBox is based on a query.
As the user types in the TextBox the ListBox will sequentially postion to
the correct record. Here is the code for the Change Event of the TextBox
that makes the sequential search work.
Private Sub Text0_Change()
Dim StrLen As Integer
Dim pos As Integer
If IsNull(Text0.Text) Then Exit Sub
pos = Len(Text0.Text)
For i = 0 To Me.List2.ListCount
If Left(Me.Text0.Text, pos) = Left(Me.List2.ItemData(i), pos) Then 'this
means the strings are equal
Me.List2.Selected(i) = True
Exit For
End If
Next i
Exit Sub
End Sub
I would like to improve on the postion of the selected record in the
ListBox. If the user is in the TextBox and hits a key and the record is not
visible in the current records showing in the ListBox, (Note: 10 records
show at a time in the listbox), then the record is selected in the Listbox
but it shows as the last record in the ListBox. Is there a way to make this
record show more in the middle of the ListBox so the user can see the records
above and below the selected record.
Thank you for your help.
Steven
As the user types in the TextBox the ListBox will sequentially postion to
the correct record. Here is the code for the Change Event of the TextBox
that makes the sequential search work.
Private Sub Text0_Change()
Dim StrLen As Integer
Dim pos As Integer
If IsNull(Text0.Text) Then Exit Sub
pos = Len(Text0.Text)
For i = 0 To Me.List2.ListCount
If Left(Me.Text0.Text, pos) = Left(Me.List2.ItemData(i), pos) Then 'this
means the strings are equal
Me.List2.Selected(i) = True
Exit For
End If
Next i
Exit Sub
End Sub
I would like to improve on the postion of the selected record in the
ListBox. If the user is in the TextBox and hits a key and the record is not
visible in the current records showing in the ListBox, (Note: 10 records
show at a time in the listbox), then the record is selected in the Listbox
but it shows as the last record in the ListBox. Is there a way to make this
record show more in the middle of the ListBox so the user can see the records
above and below the selected record.
Thank you for your help.
Steven