MarkK
bit cruncher
- Local time
- Today, 12:37
- Joined
- Mar 17, 2004
- Messages
- 8,386
Another idea about how to construct and apply a filter...
A clause assembly function, a scalable series of filter clause properties, and final assembly.
Code:
Private Function GetFilterClause(ctrl As Control, FieldName As String) As String
If Nz(ctrl.Value, "") <> "" Then GetFilterClause = "And [" & FieldName & "] LIKE '*" & ctrl.Value & "*'"
End Function
Private Property Get MfrClause() As String
MfrClause = GetFilterClause(Me.tbManufacturer, "Manufacturer")
End Property
Private Property Get PartClause() As String
PartClause = GetFilterClause(Me.tbPart, "Part")
End Property
Private Property Get OtherClause() As String
OtherClause = GetFilterClause(Me.tbOther, "Other")
End Property
Private Property Get FinalFilter() As String
Dim tmp As String
tmp = MfrClause & PartClause & OtherClause
If Len(tmp) Then FinalFilter = Mid(tmp, 5)
End Property
Sub SetFilter(State As Boolean)
If State Then Me.Filter = FinalFilter
Me.FilterOn = State
End Sub