Allen,
Thanks for your response but I am still getting the same you cancelled the
previous operation with your code. There is code before the if me.text0 = 4
line so I am enclosing it and ask that you look at it to see if there is
something in that code that may be causing this problem.
Thanks again
Private Sub FindWhat_AfterUpdate()
If Me.Text0 = 1 Then 'This Code Works Fine
Forms![ate order for specific customer].Filter = "invnum =" &
Me.ActiveControl 'AciveControl = FindWhat
Forms![ate order for specific customer].FilterOn = True
Forms![ate order for specific customer]![FilterIsOn].Visible = True
Forms![ate order for specific customer]![NotFiltered].Visible = False
Forms![ate order for specific customer]![Company].Visible = True
DoCmd.Close
GoTo goout
End If
If Me.Text0 = 2 Then 'This Code Works Fine
Forms![ate order for specific customer].Filter = "ATERefNum =" &
Me.ActiveControl
Forms![ate order for specific customer].FilterOn = True
Forms![ate order for specific customer]![FilterIsOn].Visible = True
Forms![ate order for specific customer]![NotFiltered].Visible = False
Forms![ate order for specific customer]![Company].Visible = True
DoCmd.Close
GoTo goout
End If
If Me.Text0 = 3 Then ' This code gives same problem as 4
Forms![ate order for specific customer].Filter = "invnum =" &
Me.ActiveControl
Forms![ate order for specific customer].FilterOn = True
Forms![ate order for specific customer]![FilterIsOn].Visible = True
Forms![ate order for specific customer]![NotFiltered].Visible = False
Forms![ate order for specific customer]![Company].Visible = True
DoCmd.Close
GoTo goout
End If
Dim frm As Form
Dim strFilter As String
If Me.Text0 = 4 And IsNumeric(Me.FindWhat) Then
Set frm = Forms![ate order for specific customer]
If frm.Dirty Then
frm.Dirty = flase
End If
strFilter = "CheckNum = " & Me.FindWhat
frm.Filter = strFilter 'Getting same you canceled the previous operation
error here
frm.FilterOn = True
Forms![ate order for specific customer]![FilterIsOn].Visible = True
Forms![ate order for specific customer]![NotFiltered].Visible = False
Forms![ate order for specific customer]![Company].Visible = True
DoCmd.Close
GoTo goout
End If
goout:
Set frm = Nothing
End Sub
Allen Browne said:
Don't include the form name in the Filter string.
Access will not be able to apply the filter if the form is dirty with a
record that can't be saved (e.g. validation rule not met).
Dim frm As Form
Dim strFilter As String
If Me.Text0 = 4 And IsNumeric(Me.FindWhat) Then
Set frm = Forms![ate order for specific customer]
If frm.Dirty Then 'Save any changes
frm.Dirty = False
End If
strFilter = "CheckNum = " & Me.FindWhat
frm.Filter = strFilter
frm.FilterOn = True
'show/hide your controls here.
End If
Set frm = Nothing
The data type of the CheckNum field must be the same as the value you are
trying to set it to, and must have the corrrect delimiters. If CheckNum
is
a
Number field, then FindWhat must be a number (not a word or a Null). If
CheckNum is a Text type field, you need quote marks around the value to
find, i.e.:
strFilter = "CheckNum = """ & Me.FindWhat & """"
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to the newsgroup. (Email address has spurious "_SpamTrap")
Chaster said:
I don't understand why I am getting the "You canceled the previous operation
in the code below.
Any help would be appreciated.
If Me.Text0 = 4 Then
Dim FindingWhat As Integer
FindingWhat = FindWhat 'The input box text value on my form. In this
instance 26700'
Forms![ate order for specific customer].Filter = "[all ate orders for
specific customer].CheckNum =" & FindingWhat
'Stops on above line with "You canceled the previous operation" error
Forms![ate order for specific customer].FilterOn = True
Forms![ate order for specific customer]![FilterIsOn].Visible = True
Forms![ate order for specific customer]![NotFiltered].Visible = False
Forms![ate order for specific customer]![Company].Visible = True
DoCmd.Close
End If