M
Melissa
My apologies... I am not too familiar with SQL terminology. I am learning
more and more as I read through these posts but any extra explanation you can
provide to me would be much appreciated.
Here is the filter string. I have several criteria setup to search from. But
for the purposes of this post, I am only including one of each type.
_______________________________________________________________________
Private Sub cmdFilter_Click()
Dim varFilter As Variant
'if the first control for ShipTo is filled out
If Not IsNull(Me.txtFilterShipTo) Then
'if it has multiple values
If InStr((Me.txtFilterShipTo), "~") > 0 Then
varFilter = (varFilter + " AND ") _
& "('~' & [ShipTo] & '~' in '" & Me.txtFilterShipTo & "'"
Else
'only the one value in ShipTo filter is filled out
varFilter = (varFilter + " AND ") _
& "[ShipTo]= '" & Me.txtFilterShipTo & "'"
End If
End If
If Not IsNull(Me.txtFilterState) Then
Debug.Print varFilter ' one before and....
varFilter = varFilter & " AND " _
& "[State] = '" & Me.txtFilterState & "'"
Debug.Print varFilter ' one after to view your strings
End If
If Not IsNull(Me.txtFilterEmail) Then
varFilter = (varFilter + " AND ") _
& "([EmailAddress] Like '*" _
& Me.txtFilterEmail & "*')"
End If
If Not IsNull(varFilter) Then
'remove next line after everything works ok
Debug.Print varWhere
'press CTRL-G to look at Immediate (debug) window
Me.Filter = varFilter
Me.FilterOn = True
Else
'show all records -- no filters specified
Me.FilterOn = False
End If
Me.Requery
End Sub
___________________________________________________________________
Thanks,
Melissa
more and more as I read through these posts but any extra explanation you can
provide to me would be much appreciated.
Here is the filter string. I have several criteria setup to search from. But
for the purposes of this post, I am only including one of each type.
_______________________________________________________________________
Private Sub cmdFilter_Click()
Dim varFilter As Variant
'if the first control for ShipTo is filled out
If Not IsNull(Me.txtFilterShipTo) Then
'if it has multiple values
If InStr((Me.txtFilterShipTo), "~") > 0 Then
varFilter = (varFilter + " AND ") _
& "('~' & [ShipTo] & '~' in '" & Me.txtFilterShipTo & "'"
Else
'only the one value in ShipTo filter is filled out
varFilter = (varFilter + " AND ") _
& "[ShipTo]= '" & Me.txtFilterShipTo & "'"
End If
End If
If Not IsNull(Me.txtFilterState) Then
Debug.Print varFilter ' one before and....
varFilter = varFilter & " AND " _
& "[State] = '" & Me.txtFilterState & "'"
Debug.Print varFilter ' one after to view your strings
End If
If Not IsNull(Me.txtFilterEmail) Then
varFilter = (varFilter + " AND ") _
& "([EmailAddress] Like '*" _
& Me.txtFilterEmail & "*')"
End If
If Not IsNull(varFilter) Then
'remove next line after everything works ok
Debug.Print varWhere
'press CTRL-G to look at Immediate (debug) window
Me.Filter = varFilter
Me.FilterOn = True
Else
'show all records -- no filters specified
Me.FilterOn = False
End If
Me.Requery
End Sub
___________________________________________________________________
Thanks,
Melissa