Public Function getFilter() As String
' On Error GoTo errLable
Dim strType As String
Dim [b]strManufacturer[/b] As String
Dim strSerial As String
Dim strSet As String
Dim strSubCategory As String
Dim strLocation As String
Dim andOR As String
Dim removeEnd As Integer
If Not blnSelect Then
'Need a option group with an OR button and a AND button
If Me.framAndOr.Value = 1 Then
andOR = " OR "
removeEnd = 4
Else
andOR = " AND "
removeEnd = 5
End If
'You need to do the following for each control
'qCat1 is the name of the combo that returns a
'categrogyID. The the field it is text so need
'single quotes.
'The variable is strType which is a bad name. Should be something like strCAT
If Not Trim(Me.qCat1 & " ") = "" Then
strType = "[CategoryID] = '" & qCat1 & "'" & andOR
End If
'So for the next control, the control name is qSerial
'the field is Serial and is returns as string
'saving the result in strSerial
If Not Trim(Me.qSerial1 & " ") = "" Then
strSerial = "[Serial] = '" & qSerial1 & "'" & andOR
End If
'So for the next control, the control name is qMan
'the field is ManufacturerID and is returns as string
'saving the result in strManufacturer
If Not Trim(Me.[b]qMan1[/b] & " ") = "" Then
strManufacturer = "[b][ManufacturerID][b/] = '" & [b]qMan1[/b] & "'" & andOR
End If
If Not Trim(Me.qSub1 & " ") = "" Then
strSubCategory = "[SubCategoryID] = " & qSub1 & andOR
End If
If Not Trim(Me.qSet1 & " ") = "" Then
strSet = "[Set] = '" & qSet1 & "'" & andOR
End If
If Not Trim(Me.qLoc1 & " ") = "" Then
strLocation = "[LocationID] = '" & qLoc1 & "'" & andOR
End If
getFilter = strType + strSerial + strManufacturer + strSet + strLocation + strSubCategory
getFilter = Left(getFilter, Len(getFilter) - removeEnd)
Else
If Not IsNull(lstSearch) Then
getFilter = "[ToolID] = " & Me.lstSearch
End If
End If
'You may comment this out
Debug.Print "Filter Criteria: " & getFilter
Exit Function
errLable:
MsgBox Err.Number & " " & Err.Description
End Function