Go to design view
Click on cmdGo button
On Property Sheet go to events tab
Click the dropdown menu on on click
Select Event Procedure
insert the following:
Repeat the top except instead of clicking the on click, click On Got Focus![]()
Private Sub cmdGo_Click() Dim strSearch As String Dim strFilter As String On Error GoTo cmdGo_Click_Err If IsNull(Me.SearchBox) Then ' Clear Filter when search box empty DoCmd.RunCommand acCmdRemoveFilterSort Me.cmdShowAll.Enabled = False GoTo cmdGo_Click_Exit End If ' Handle "'s in search strSearch = Replace(Me.SearchBox, """", """""") ' Build the Filter strFilter = "([Contact Name] Like ""*" & strSearch & "*"")" strFilter = strFilter & " OR ([Hospital / Clinic Name (Arabic)] Like "" * " & strSearch & " * "" )" strFilter = strFilter & " OR ([Hospital / Clinic Name (English)] Like "" * " & strSearch & " * "" )" DoCmd.ApplyFilter "", strFilter Me.cmdShowAll.Enabled = True cmdGo_Click_Exit: Exit Sub cmdGo_Click_Err: MsgBox Error$ Resume cmdGo_Click_Exit End Sub
That will make it so if you hit tab or enter when you are done typing it will apply the filter.![]()
Private Sub cmdGo_GotFocus() Call cmdGo_Click End Sub
Hope this helps,
Dan
Bookmarks