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
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