You canceled previous operation

S

swanner

This message appears when I execute Run Query command using a command
button on a form. I deleted the button and two combo boxes and started
over again creating new combo boxes and a new command button.....I got
the same message. The two combo boxes are date boxes, one a start date
and the other an end date, both of which are used in the criteria on a
query named PO. The query runs fine when I run the query and input the
start and end date, but when I try running it with the command button I
get the "You Canceled Previous Operation" pop-up error box.

Thanks for your help.
Jim
 
A

Allen Browne

Jim, the message might indicate that the query statement is incorrect.

If you cannot see what is wrong with it, post the code you are using, and if
it is a saved query, switch it to SQL View (View menu in query design) and
post the query statement as well.
 
W

Wayne Morgan

Please post the code you're using to run the query and the SQL view of the
query.
 
D

Douglas J Steele

By any chance do you have a DLookup in your code?

I believe Access issues that misleading error message if you're mispelled a
field or table name in the DLookup statement.
 
S

swanner

Allen, here is the code for the query and for the button.

FOLLOWING IS CODE FOR QRY

SELECT POTbl.POId, POTbl.POId+1000 AS PONumber, POTbl.VendId,
POTbl.PODate, POTbl.ReqShpDate, POTbl.ArrivDate, POTbl.ShipVia,
POTbl.PONotes, POTbl.IsDeleted, PODtlTbl.ItemNo, PODtlTbl.OrdQty,
PODtlTbl.POCost, PODtlTbl.Port, PODtlTbl.IsDeleted
FROM POTbl LEFT JOIN PODtlTbl ON POTbl.POId = PODtlTbl.POId
WHERE (((POTbl.PODate) Between [Forms]![PurchasingFrm]![StartDateCombo]
And [Forms]![PurchasingFrm]![EndDateCombo]));

..............................................................................................................................

CODE FOR POByDateBtn

Option Compare Database
Private Sub POByDateBtn_Click()
On Error GoTo Err_POByDateBtn_Click

Dim stDocName As String

stDocName = "POByPODateQry"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_POByDateBtn_Click:
Exit Sub

Err_POByDateBtn_Click:
MsgBox Err.Description
Resume Exit_POByDateBtn_Click

End Sub

I hope this is what you wanted.
Jim
 
W

Wayne Morgan

Jim,

I would recommend the following line be added to the top of your query:

PARAMETERS [Forms]![PurchasingFrm]![StartDateCombo] DateTime,
[Forms]![PurchasingFrm]![EndDateCombo] DateTime;
SELECT .....

This will tell the query that your parameters are of the Date/Time data
type. It will sometimes not realize that unless you tell it.

Also, the error handler doesn't trap the 2501 (You cancelled the
previous...) error. Amend your error handler to something like:
Err_POByDateBtn_Click:
If Err.Number said:
MsgBox Err.Description
Resume Exit_POByDateBtn_Click
Else
Resume Next
End If


--
Wayne Morgan
MS Access MVP


Allen, here is the code for the query and for the button.

FOLLOWING IS CODE FOR QRY

SELECT POTbl.POId, POTbl.POId+1000 AS PONumber, POTbl.VendId,
POTbl.PODate, POTbl.ReqShpDate, POTbl.ArrivDate, POTbl.ShipVia,
POTbl.PONotes, POTbl.IsDeleted, PODtlTbl.ItemNo, PODtlTbl.OrdQty,
PODtlTbl.POCost, PODtlTbl.Port, PODtlTbl.IsDeleted
FROM POTbl LEFT JOIN PODtlTbl ON POTbl.POId = PODtlTbl.POId
WHERE (((POTbl.PODate) Between [Forms]![PurchasingFrm]![StartDateCombo]
And [Forms]![PurchasingFrm]![EndDateCombo]));

.............................................................................................................................

CODE FOR POByDateBtn

Option Compare Database
Private Sub POByDateBtn_Click()
On Error GoTo Err_POByDateBtn_Click

Dim stDocName As String

stDocName = "POByPODateQry"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_POByDateBtn_Click:
Exit Sub

Err_POByDateBtn_Click:
MsgBox Err.Description
Resume Exit_POByDateBtn_Click

End Sub

I hope this is what you wanted.
Jim
 
S

swanner

I finally found the cause and it is something I did. After setting up
the form, combo box and query, I edited the number of digits in the
properties of the StartDate and EndDate fields of the combo box. I
corrected my error and the form and query ran fine.

Thanks for the help.
Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top