G
Guest
I am getting to my wits end with this problem and I am
hoping someone can help me, I really need this to work.
I am using this code to filter a form the first three
work great but when I try to use it on a date field I
keep getting "Run-time error '2001' You canceled the
previous operation". When I go to debug it
has "Me.Filter = (left(strWhere, LngLen) is highlighted.
Dim strWhere As String
Dim lngLen As Long
If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If
If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "
End If
If Not IsNull(Me.cbocontact) Then
strWhere = strWhere & "([ratm_contact] = """ & _
Me.cbocontact & """) AND "
End If
If Not IsNull(Me.cbobusiness) Then
strWhere = strWhere & "([business_unit] = """ & _
Me.cbobusiness & """) AND "
End If
If Not IsNull(Me.cborescomplete) Then
strWhere = strWhere & "([research_completed] = """ & _
Me.cborescomplete & """) AND "
End If
'etc for other search boxes.
lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen <= 0 Then
MsgBox "No criteria."
Else
Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True
Thanks in advance
hoping someone can help me, I really need this to work.
I am using this code to filter a form the first three
work great but when I try to use it on a date field I
keep getting "Run-time error '2001' You canceled the
previous operation". When I go to debug it
has "Me.Filter = (left(strWhere, LngLen) is highlighted.
Dim strWhere As String
Dim lngLen As Long
If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If
If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "
End If
If Not IsNull(Me.cbocontact) Then
strWhere = strWhere & "([ratm_contact] = """ & _
Me.cbocontact & """) AND "
End If
If Not IsNull(Me.cbobusiness) Then
strWhere = strWhere & "([business_unit] = """ & _
Me.cbobusiness & """) AND "
End If
If Not IsNull(Me.cborescomplete) Then
strWhere = strWhere & "([research_completed] = """ & _
Me.cborescomplete & """) AND "
End If
'etc for other search boxes.
lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen <= 0 Then
MsgBox "No criteria."
Else
Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True
Thanks in advance