Ok I Idk why i cna't do this any more (seeing as I did it back in 2010, oh well.
Purpose: To create a form [Search]that contain 3 unbound text fields (Filter1, Filter2, and Filter3). When one clicks the search aka (cmdFilter) the subform [Search Results] is filtered based on the 3 text fields.
What I need help on: I need a VB code the will make the filter go from one Filter to the other then show results in the sub form.
Example:
Filter1: Smith
Filter2: John
Filter3: (Blank)
Sub form results:
Smith John A.
Smith John D.
etc....
* Form called [Search] has no record source ie unbound
* Form called [Search Results] has a record source of qrySearch
This is what I have as my code so far, but I know it isn't correct... looks off. Please help
Purpose: To create a form [Search]that contain 3 unbound text fields (Filter1, Filter2, and Filter3). When one clicks the search aka (cmdFilter) the subform [Search Results] is filtered based on the 3 text fields.
What I need help on: I need a VB code the will make the filter go from one Filter to the other then show results in the sub form.
Example:
Filter1: Smith
Filter2: John
Filter3: (Blank)
Sub form results:
Smith John A.
Smith John D.
etc....
* Form called [Search] has no record source ie unbound
* Form called [Search Results] has a record source of qrySearch
This is what I have as my code so far, but I know it isn't correct... looks off. Please help
Code:
Private Sub cmdFilter_Click()
Dim strWhere As String
If Not IsNull(Me.Filter1) Then
strWhere = strWhere & "([Search Results]![SNN] Like ""*" & Me.Filter1 & "*"") AND "
End If
If Not IsNull(Me.Filter1) Then
strWhere = strWhere & "([Search Results]![Last Name] Like ""*" & Me.Filter1 & "*"") AND "
End If
If Not IsNull(Me.Filter1) Then
strWhere = strWhere & "([Search Results]![First Name] Like ""*" & Me.Filter1 & "*"") AND "
End If
If Not IsNull(Me.Filter2) Then
strWhere = strWhere & "([Search Results]![SNN] Like ""*" & Me.Filter2 & "*"") AND "
End If
If Not IsNull(Me.Filter2) Then
strWhere = strWhere & "([Search Results]![Last Name] Like ""*" & Me.Filter2 & "*"") AND "
End If
If Not IsNull(Me.Filter2) Then
strWhere = strWhere & "([Search Results]![First Name] Like ""*" & Me.Filter2 & "*"")"
End If
' And same for Filter 3
End Sub
Comment