oxicottin
Learning by pecking away....
- Local time
- Today, 01:27
- Joined
- Jun 26, 2007
- Messages
- 870
Hello, I can't figure out what I'm missing in this filtered search. It either says I'm missing a ) or I have an extra ) in my query expression. Its one of my 3 searches I have causing it.
Code:
'*********************************FILTER SEARCH START*********************************
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim lngLen As Long
varWhere = Null ' Main filter
'*************************************************************************************
'Look at each search box, and build up the criteria string from the non-blank ones.
'*************************************************************************************
'-------------------------------------------------------------------------------------------------------
' Check For Employee
If Not IsNull(Me.cboEmployees) Then
varWhere = varWhere & "([EmployeeID] = " & Me.cboEmployees & ") AND "
End If
'-------------------------------------------------------------------------------------------------------
' Check year
If Not IsNull(Me.cboYear) Then
varWhere = varWhere & "Year([DateOfIncident] = " & Me.cboYear & ") AND "
End If
'-------------------------------------------------------------------------------------------------------
' Check For Verbal,Written,Suspension
If Not IsNull(Me.optContactGroup) Then
If Me.optContactGroup.Value = 1 Then
varWhere = varWhere & "([Contact] = " & Me.optContactGroup & ") AND "
Else
varWhere = varWhere & "([Contact] = " & Me.optContactGroup & ") AND "
End If
End If
'-------------------------------------------------------------------------------------------------------
' Check if there is a filter to return...
If IsNull(varWhere) Then
varWhere = ""
' msg if no data
'MsgBox "No criteria", vbInformation, "Nothing to do."
Me.FilterOn = True
Else
varWhere = "WHERE " & varWhere
' strip off last "AND" in the filter
If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
End If
End If
BuildFilter = varWhere
Me.txtFilterResult = varWhere
'Debug.Print BuildFilter
End Function
'
'*********************************FILTER SEARCH END***********************************