M
missamay
Hi, I am creating a search function based on a selection made from a
combo box. I have a combo box cmbSearchState and a command buttons
cmdSearchState and cmdClearState.
So far I'm using some code from Allen Browne that he posted previously
which works well (Thanks Allen!).
For the Search button
Private Sub cmbStateSearch_Click()
Dim strFilter As String
If IsNull(Me.cmbSearchState) Then
MsgBox "What state abrevation?"
Else
If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If
strFilter = "[State1] = """ & Me.cmbSearchState & """"
Me.Filter = strFilter
Me.FilterOn = True
End If
End Sub
And for the Clear button (cmdClearState)
Private Sub cmbClearState_Click()
If Me.Dirty Then 'Save before remove filter
Me.Dirty = False
End If
Me.FilterOn = False
However, I want the code to search several fields including [State2],
[State3], and [State4], but I don't know how to change the code to get
it work. I tried using an OR Statement between the fields, but that did
not work. I also tried adding other IF/THEN Statements to include the
other fields, but that did not work either. Any help would be
appreciated.
Thanks,
Melissa
combo box. I have a combo box cmbSearchState and a command buttons
cmdSearchState and cmdClearState.
So far I'm using some code from Allen Browne that he posted previously
which works well (Thanks Allen!).
For the Search button
Private Sub cmbStateSearch_Click()
Dim strFilter As String
If IsNull(Me.cmbSearchState) Then
MsgBox "What state abrevation?"
Else
If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If
strFilter = "[State1] = """ & Me.cmbSearchState & """"
Me.Filter = strFilter
Me.FilterOn = True
End If
End Sub
And for the Clear button (cmdClearState)
Private Sub cmbClearState_Click()
If Me.Dirty Then 'Save before remove filter
Me.Dirty = False
End If
Me.FilterOn = False
However, I want the code to search several fields including [State2],
[State3], and [State4], but I don't know how to change the code to get
it work. I tried using an OR Statement between the fields, but that did
not work. I also tried adding other IF/THEN Statements to include the
other fields, but that did not work either. Any help would be
appreciated.
Thanks,
Melissa