Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem filtering a continuous form with VBA

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
586
GB
Hello, I am using the folloing code to filter a continuous form after updating a text box [property_find]

The filter works fine as long as results are returned. If no results are returned after the filter is run, the filter will not run again and gives the error:

You can't reference a property or method for a control unless the control has focus

Could someone kindly point me in the right direction to make the code

a. work
b. more robust.



Many thanks Mark


Private Sub txtProperty_find_AfterUpdate()
Dim strFilter As String

On Error GoTo ErrHandler

If Me.txtProperty_find.Text <> "" Then
strFilter = "[Property Address (1)] Like '*" & Me.txtProperty_find.Text & "*'"
Me.Filter = strFilter
Me.FilterOn = True
Me.OrderBy = "[property status] ASC, [property address (1)] ASC,[property no] ASC"
Me.OrderByOn = True

Else
Me.Filter = ""
Me.FilterOn = False
Me.OrderBy = "[property status] ASC, [property address (1)] ASC,[property no] ASC"
Me.OrderByOn = True

End If


Exit Sub

ErrHandler:
MsgBox err.Description, vbExclamation


End Sub
 
I'd replace .Text with .Value

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top