A
Allen Browne
You need an example to follow?
Dim strWhere As String
Dim lngLen As Long
If Not IsNull(Me.cbo1) Then 'numeric example
strWhere = strWhere & "([SomeNumberField] = " & Me.cbo1 & ") AND "
End If
If Not IsNull(Me.cbo2) Then 'text example
strWhere = strWhere & "([SomeTextField] = """ & Me.cbo2 & """) AND "
End If
If Not IsNull(Me.cbo3) Then 'date example
strWhere = strWhere & "([SomeDateField] = #" & Me.cbo3 & "#) AND "
End If
lngLen = Len(strWhere) - 5 'Without trailing " AND "
If lngLen < 0 Then
MsgBox "No criteria
Else
If Me.Dirty Then 'Save before filter.
Me.Dirty = False
End If
Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True
End If
Dim strWhere As String
Dim lngLen As Long
If Not IsNull(Me.cbo1) Then 'numeric example
strWhere = strWhere & "([SomeNumberField] = " & Me.cbo1 & ") AND "
End If
If Not IsNull(Me.cbo2) Then 'text example
strWhere = strWhere & "([SomeTextField] = """ & Me.cbo2 & """) AND "
End If
If Not IsNull(Me.cbo3) Then 'date example
strWhere = strWhere & "([SomeDateField] = #" & Me.cbo3 & "#) AND "
End If
lngLen = Len(strWhere) - 5 'Without trailing " AND "
If lngLen < 0 Then
MsgBox "No criteria
Else
If Me.Dirty Then 'Save before filter.
Me.Dirty = False
End If
Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True
End If