Hi All.
I created continuous form and trying create filter textbox. Online I found code exactly that I expecting to create.
But unfortunately it doesn't work. If it possible to fix the bug. Can someone show how it to do? Or may exist other similar idea. I will appreciate for help.
Thanks
I created continuous form and trying create filter textbox. Online I found code exactly that I expecting to create.
Code:
Private Sub txtNameFilter_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(txtNameFilter.Text) > 0 Then
filterText = txtNameFilter.Text
Me.Form.Filter = "[Contacts]![first_name] LIKE '*" & filterText & "*' OR [Contacts]![last_name] LIKE '*" & filterText & "*'"
Me.FilterOn = True
'Retain filter text in search box after refresh.
txtNameFilter.Text = filterText
txtNameFilter.SelStart = Len(txtNameFilter.Text)
Else
' Remove filter.
Me.Filter = ""
Me.FilterOn = False
txtNameFilter.SetFocus
End If
Exit Sub
errHandler:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly, "Error ..."
End Sub
Thanks