Link to home
Create AccountLog in
Avatar of DJ P
DJ PFlag for United States of America

asked on

MS Access Invalid Use of Property

Hello Experts. I have a form based off a query. The form is continuous and I have an unbound text box call txtSearch. The goal is to perform a search on two fields on the form. Below is my code but as soon as I type in the search box I receive an error: Invalid Use of Property. No clue how to reslove.

Option Compare Database

Private Sub txtSearch_Click()

End Sub

Private Sub txtSearch_KeyUp(KeyCode As Integer, Shift As Integer)

On Error GoTo errHandler

Dim filterText As String

'Apply or update filter based on user input.

If Len(txtSearch.Text) > 0 Then

   filterText = txtSearch.Text

   Me.Form Filter = "[frmselect]![] Like '*" & filterText & "*' or [frmselect]![variant_name] Like '*" & filterText & "*'"

   Me.FilterOn = True

'Retain filter text in search after refresh

    txtSearch.Text = filterText

    txtSearch.SelStart = Len(txtSearch.Text)


  ' Remove Filter

  Me.Filter ""

  Me.FilterOn = False


  End If


  Err Handler:


  MsgBox Err.Number & " - " & Err.Description, vbOKOnly, "Error ..."


End Sub


Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account