J
Jack
Hi,
I got a form and trying to test a code by applying filter. This filter is a
value chosen by a user using a combo box. However when I am running the form
with the click of the filter I am getting an error message "You cancelled a
previous operation" I am getting this error.
Code for filter:
Private Sub cmdFilter_Click()
Dim strwhere As String
Dim lngLen As Long
If Not IsNull(Me.cboFilterIsPrefix) Then
strwhere = strwhere & "([Prefix] = " & Me.cboFilterIsPrefix & ") AND "
End If
lngLen = Len(strwhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the "
AND " at the end.
strwhere = Left$(strwhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to
Immediate Window (Ctrl+G).
'Debug.Print strWhere
'Finally, apply the string as the form's Filter.
Me.Filter = strwhere
Me.FilterOn = True
End If
End Sub
While I am on debug mode I saw that the error is coming at the line
Me.FilterOn = True line.
Any help is appreicated. Thanks.
I got a form and trying to test a code by applying filter. This filter is a
value chosen by a user using a combo box. However when I am running the form
with the click of the filter I am getting an error message "You cancelled a
previous operation" I am getting this error.
Code for filter:
Private Sub cmdFilter_Click()
Dim strwhere As String
Dim lngLen As Long
If Not IsNull(Me.cboFilterIsPrefix) Then
strwhere = strwhere & "([Prefix] = " & Me.cboFilterIsPrefix & ") AND "
End If
lngLen = Len(strwhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the "
AND " at the end.
strwhere = Left$(strwhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to
Immediate Window (Ctrl+G).
'Debug.Print strWhere
'Finally, apply the string as the form's Filter.
Me.Filter = strwhere
Me.FilterOn = True
End If
End Sub
While I am on debug mode I saw that the error is coming at the line
Me.FilterOn = True line.
Any help is appreicated. Thanks.