Search List box with Text Box

aron.ridgway

Registered User.
Local time
Today, 21:39
Joined
Apr 1, 2014
Messages
148
Hi there

i have got the bellow code that filters a listbox which is based on a query, from a textbox. The code works fine and it Filters, but if i put in too many characters that do not exsit in the data( so it cant display any results) i get an error saying Run time error 2105 - You cant go to the Specified record?

Has anyone got any tips on how i can catch this error so it does nothing apart from display a blank listbox with no error?

Code:
Private Sub txtSearch_Change()
Me.lstShowSupplier.Requery
DoCmd.Requery
Me.txtSearch.SetFocus
If Not IsNull(Len(Me.txtSearch)) Then
        Me.txtSearch.SelStart = Len(Me.txtSearch)
    End If
 
End Sub
 
Hi

the if statement is for selecting the end of the data in the text box, so its constantly updating the listbox after each key press? Is this what is also causing the error?

thanks
 

Users who are viewing this thread

Back
Top Bottom