I have an Access 2010 Database. The data is in SQL Server. I've been asked to add a search routine to the main data form.
I've added a command button to open a form with 2 textboxes for the user to type in what they're searching for.
Code:
DoCmd.OpenForm "frm_namesearch", acNormal
Me.Filter = strfind
Me.FilterOn = True
strfind is a public string variable in a public module
There is also a command button for the user to apply the filter.
This is the code in the search command button
Code:
If Not IsNull(Me.txtlast) And IsNull(Me.txtfirst) Then
strfind = "Lastname Like ""*" & Me.txtlast & "*"""
Else
If IsNull(Me.txtlast) And Not IsNull(Me.txtfirst) Then
strfind = "Firstname Like ""*" & Me.txtfirst & "*"""
Else
strfind = "lastname Like ""*" & Me.txtlast & "*"" and firstname like ""*" & Me.txtfirst & "*"""
End If
End If
Now what I'd like to happen is once the user clicks on the command button this form closes and goes back to the original form and the strfind be applied to the form filter.
I tried adding a me.close to the command button that builds the find string but it doesn't work just gives me an error. Any help is appreciated.