You canceled the previous operation...


Hi, I have the (really helpfull) error "You canceled the previous operation" coming up on the piece of code marked with a string of stars below:

Dim IntMaxRev As Integer
Dim strOpen As String

strOpen = "[ProjectNumber] = '" & Me.ProjNo & "' and [PNo] = " & Me.PNo
IntMaxRev = Nz(DMax("Rev", "TblPMain", strOpen), 0) *****

Any ideas why?


Sponsored Links:



Hi

I'm using the following vba to reset the record source i.e. (Me.RecordSource = strFilter)

strFilter = "SELECT * FROM tblApplication INNER JOIN tblCustomer ON tblApplication.cust_id = tblCustomer.cust_id " & _
"WHERE (tblCustomer.cust_short_name) = " & [Forms]![frmApplication]![cboCustomerSearch] & ";"

Unfortunately I get an error message;
"runtime error '2001' you cancelled the previous operation"
From other post I believe the error is in the SQL.

Any ideas anyone. Your help would be greatly appreciated

Cheers




I have some code in a command button on a form that generates Error 2001: "You cancelled the previous operation."

I've searched this forum for fixes, and the only suggestion I found which might work for me is creating a new database and importing everything from the current one. I've tried this and it doesn't work - I get the same problem. So I don't think it's being caused by a corrupt database.

Here's my code:

Private Sub Command37_Click()
On Error GoTo Command37_Click_Error

DoCmd.SetWarnings False

DoCmd.OpenQuery "qryCheckImportedTotals"

If (DCount("*", "tblSSTotalsExceptions", "(([tblSSTotalsExceptions].[Year] = [tblImportedTest].[Year]) AND ([tblSSTotalsExceptions].[Payno] = [tblImportedTest].[Pay No]) AND ([tblSSTotalsExceptions].[Week] = [tblImportedTest].[Week No]))") > 0) Then

If (MsgBox("The totals listed on the Excel spreadsheets don't match the sum total of the individual records. Would you like to see tblSSTotalsExceptions?", vbYesNo + vbQuestion) = vbYes) Then
DoCmd.OpenTable "tblSSTotalsExceptions"
End If
End If

DoCmd.SetWarnings True

Command37_Click_Exit:
Exit Sub

Command37_Click_Error:
MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
Resume Command37_Click_Exit

End Sub

When I Debug, the problem registers on the "If (DCount ..." line.

Does anyone know what's causing this problem, and how I might fix it?

thanks!




I have a form with several subforms. The other day after adding some if-then code to automate the data entry a bit, I attempted to add a macro as well. After doing this, I received some strange messages about adding a module (which I was not trying to do but believe happened automatically through the macro). Then i received a message "you cancelled the previous operation" and since then have not been able to open my form or subform.

I have searched online for a solution to this, and it seems they are all geared towards changing the code in the form that is having the problem. However, I cannot even open my forms. Any ideas for me? Or shall I have to re-create the form and subform that I cannot open?

Any help will be appreciated,
eh




I've got the following piece of code which usually works ok, but for some reason I can't fathom it's started coming up with Runtime Error '2001': You cancelled the previous operation. I've been unable to find a reference for what this actually means because all the values are in the right place when I go to debug it. The code is pasted below - it's a bit long but any help would be appreciated.

Thanks in advance,
Sharon

Private Sub cmdAdditPresc_Click()
'Display other prescriptions that have to be observed in addition to current tier

Dim strSQL As String
Dim strSQL2 As String
Dim strPrescNo As String
Dim strPrescNo2 As String
Dim strPrescNo3 As String

If Forms!frmDisplayPrescriptions.ESAName = "Broads" Then
Select Case Forms!frmDisplayPrescriptions.AESISCode
Case "OO2"
strPrescNo = 17
Case "OO3"
strPrescNo = 26
Case "O4A"
strPrescNo = 17
Case Else
MsgBox "There are no previous prescriptions for this tier"
Exit Sub
End Select
ElseIf Forms!frmDisplayPrescriptions.ESAName = "Breckland" Then
Select Case Forms!frmDisplayPrescriptions.AESISCode
Case "OO2"
strPrescNo = 8
Case "OO3"
strPrescNo = 8
Case "O4A"
strPrescNo = 8
Case "O4B"
strPrescNo = 8
Case "OO1"
strPrescNo = 8
Case Else
MsgBox "There are no previous prescriptions for this tier"
Exit Sub
End Select
ElseIf Forms!frmDisplayPrescriptions.ESAName = "Dartmoor" Then
Select Case Forms!frmDisplayPrescriptions.AESISCode
Case "O1B"
strPrescNo = 21
Case "O1C"
strPrescNo = 21
Case "O1D"
strPrescNo = 21
Case "O1E"
strPrescNo = 21
Case "2BR"
strPrescNo = 21
Case Else
MsgBox "There are no previous prescriptions for this tier"
Exit Sub
End Select
ElseIf Forms!frmDisplayPrescriptions.ESAName = "Lake District" Then
Select Case Forms!frmDisplayPrescriptions.AESISCode
Case "O1B"
strPrescNo = 18
Case "O1C"
strPrescNo = 18
strPrescNo2 = 19
strPrescNo3 = 27
Case "O1D"
strPrescNo = 18
Case "O1E"
strPrescNo = 18
strPrescNo2 = 30
strPrescNo3 = 34
Case "O2A"
strPrescNo = 18
strPrescNo2 = 19
strPrescNo3 = 27
Case "O2B"
strPrescNo = 18
strPrescNo2 = 30
strPrescNo3 = 38
Case "O2D"
strPrescNo = 18
strPrescNo2 = 19
strPrescNo3 = 27
Case Else
MsgBox "There are no previous prescriptions for this tier"
Exit Sub
End Select
End If

strSQL = "SELECT DISTINCT tblESAReference.ESAName, tblAllSchemes.AESISCode, tblAllSchemes.TierNum, tblAllSchemes.Title, tblTiersSupps.PrescriptionNumber, tblTiersSupps.Prescription, tblESAReference.ESAID FROM (tblESAReference INNER JOIN tblAllSchemes ON tblESAReference.ESAID = tblAllSchemes.ESAID) INNER JOIN tblTiersSupps ON tblAllSchemes.RowID = tblTiersSupps.RowID WHERE (((tblESAReference.ESAName)=[Forms]![frmSecondSelectESA]![cboESA]) AND ((tblTiersSupps.PrescriptionNumber) Between '1' And '" & strPrescNo & "'))"
strSQL2 = "SELECT DISTINCT tblESAReference.ESAName, tblAllSchemes.AESISCode, tblAllSchemes.TierNum, tblAllSchemes.Title, tblTiersSupps.PrescriptionNumber, tblTiersSupps.Prescription, tblESAReference.ESAID FROM (tblESAReference INNER JOIN tblAllSchemes ON tblESAReference.ESAID = tblAllSchemes.ESAID) INNER JOIN tblTiersSupps ON tblAllSchemes.RowID = tblTiersSupps.RowID WHERE (((tblESAReference.ESAName)=[Forms]![frmSecondSelectESA]![cboESA]) AND ((tblTiersSupps.PrescriptionNumber) Between 1 And '" & strPrescNo & "')) OR (((tblESAReference.ESAName)=[Forms]![frmSecondSelectESA]![cboESA]) AND ((tblTiersSupps.PrescriptionNumber) Between '" & strPrescNo2 & "' And '" & strPrescNo3 & "'))"


DoCmd.OpenForm "frmDisplayPreviousPrescriptions"

Select Case Forms!frmDisplayPrescriptions.ESAName
Case "Lake District"
Forms!frmDisplayPreviousPrescriptions.RecordSource = strSQL2
Case Else
Forms!frmDisplayPreviousPrescriptions.RecordSource = strSQL
End Select


End Sub




I know this error is well covered ground but all the solutions suggested have not worked and it's driving me to distraction!!!!

I've created a form that allows a user to select a date from a combo box and a colleague from another combo box then click a button which builds a filter string and applies it to the form. The code for the button is as follows:

Private Sub Command64_Click()
Dim strDate As String
Dim strFilter As String

If IsNull(Me.cmbColleague) Or IsNull(Me.cmbDate) Then
MsgBox "Please select both a date and a colleague before clicking Refresh.", vbExclamation, "Error"
Exit Sub
End If

strDate = Format(Me.cmbDate, "mm/dd/yyyy")
strFilter = "AddedBy = " & Me.cmbColleague & " AND DateAdded = #" & strDate & "#"

Me.FilterOn = True
Me.Filter = strFilter
End Sub

AddedBy is the field containing an employee number and is a text type field. cmbColleague is a combo box using a query to pull all registered employees from the Colleagues table.

DateAdded is a date field containg the date the record was added. cmbDate is a combo box using a query to pull all the dates from the database.

Now this is the part I don't get. If I shorten the filter to just the date or just the colleague, it works fine. It's a soon as I try to filter on both that I get the error; "You cancelled the previous operation" on the last line of the code.

I've tried setting the filter then turning it on and as it is now turning on the filter first then setting it. I've tried setting up a new form but it's not working either.

Like I say the most baffling thing is it'll let me filter on one criteria but not both, and as far as I know i'm creating the multiple criteria filter correctly, or am I?

Any help would be hugely appreciated!!




I have this code

Private Sub Command4_Click()

'between 1/1/2003 AND 1/1/04
Dim myDate As Variant
myDate = "BETWEEN "
myDate = myDate & Me.StartDate
myDate = myDate & " AND "
myDate = myDate & Me.EndDate

FullDate.SetFocus
Me.FullDate.Text = myDate

DoCmd.OpenQuery "qryMain", acViewNormal
'DoCmd.Close acQuery, "qryMain"
'DoCmd.OpenReport "ComboBox2", acViewPreview
End Sub


On this line
DoCmd.OpenQuery "qryMain", acViewNormal

It give me the Error You Cancelled the Previous Operation. What is causing this to happen.

I also am having a query read from the text box what the value of the query will be. See Attached. Thanks for any ideas!




Hi, I've been progamming Access for a couple of years so am not a complete novice but I can't seem to work out this problem.
I downloaded some code from "databasedev.co.uk" from the query section called "Using a Microsoft Access listbox to pass criteria to a query". It works fine. However when I import my own table and change the code to SELECT the imported table and change the WHERE statement to my new string within that table , I get an error. When I select from the list box and click the command button I get the message "You canceled the previous operation".
However if I select the "ALL" selection from the list box it does return all the records.

Any help would be gratefully received!

JeffT




I have subform where access lists orderitems(the main form contains the order info). The subform uses a query to lookup items thats in the orderlist. Everything works fine execpt when I change something in a dropdowncombo list in the orderlist sheet(like in sample northwind db) the I get "You cancelled the previous operation". The post IS changed and everything seems to work nice but why do I get this error?

The combo uses "SELECT DISTINCT Items.IDItem, Items.Item FROM Items;" as rowsource and also "ListedItems.IDItem" as controlsource.




The code below is from a form named frmWorkorderComplete I use to append the tblWorkordersComplete table with data from the fields in the table tblWorkOrders. I'm trying to prevent duplicate entries in the tblWorkOrdersComplete table. To do this, I create a unique identifier for each record to be appended by combining the "ordered", "company", and "salescategory" into a string which is inserted into the "wonmbr" primary key field of the tblWorkorderComplete.

The following code is used in the subroutine to check if a particular wonmbr has already been appended. However, I keep receiveing the error: "Runtime Error 2001- You cancelled the previous operation" EVERYTHING else in this sub routine works fine when I remove the offending code:

If DCount("[wonmbr]", "tblWorkorderComplete", "[wonmbr] = str_wonmbr") > 0 Then
MsgBox "Workorder Already Appended!"
Exit Sub
Else


///////////////////////////
Private Sub Archive_Click()

' declare variables
Dim Variable1 As String
Dim Variable2 As String
Dim Variable3 As Date
Dim Variable4 As Date
Dim Variable5 As Date
Dim Variable6 As Date
Dim Variable7 As Date
Dim str_wonmbr As String
Dim strI As String
Dim strS As String
Dim strSQL As String

Variable1 = [company]
Variable2 = [salecategory]
Variable3 = [ordered]
Variable4 = [filled]
Variable5 = [billed]
Variable6 = [shipped]
Variable7 = [received]

' Create the unique identifier
str_wonmbr = Format([ordered], "yyyy-mm-dd") & "-" & [company] & "-" & [salescategory]

' HERE IS THE OFFENDING CODE
If DCount("[wonmbr]", "tblWorkorderComplete", "[wonmbr] = str_wonmbr") > 0 Then
MsgBox "Workorder Already Archived!"
Exit Sub
Else

' build SQL string
strI = "INSERT INTO tblWorkordersComplete (wonmbr, company, salescategory, ordered ) "
strS = "SELECT '" & str_wonmbr & "', '" & Variable1 & "', #" & Variable3 & "#, #" & Variable4 & "#, #" & Variable5 & "#, #" & Variable6 & "#, #" & Variable7 & "#;"
strSQL = strI & strS

' run SQL code and append data
DoCmd.RunSQL strSQL

End If
End Sub




I'm in a bit of a pickle here.

Please forgive if I don't use the correct terminology here; the phrase " a little knowlege is dangerous" springs to mind in this situation.

Whilst trying to create a more complicated conditional format than could be handled by the conditional formatting "wizard" I entered some code into the VBA Editor and now I can't access my form.

When I try and access it via the "Direct to Reservations" button (circled below) I keep getting the "You canceled the previous operation" error message:



When I try to access the form via the database window, nothing happens.

Obviously, I can't get into the form to access the VBA Editor to see what I did but I recall it was an "After Update" command; I've managed to get into the VBA Editor (I think !) via the table and below is what is in there for the offending field:



I've tried to delete the code but every time I try and do that, the database closes down saying there's been an error.

To make matters worse, in trying to use an append query to transfer data from my back up I've created duplicates of everything so now the table has 5200 records where it should be 2600 !

The whole question of duplicate records is another subject; to be honest, I'd just like to get rid of the offending code (or whatever it's called) so that I can get into the form again, I'll worry about the duplicates later.

Please Help !!!!!




Hi All,

Can some body correct the following code please, as I am stuck with it...

Me.RecomVendor = Nz(DLookup(Nz("RecommVendor", ""), "tblPettyCash", "[dn] = '" & Me!PCPNo & "'"), "")

Note : All of them are text fields...

I get " You cancelled the previous operation" error while i run it, please some body solve it for me, it will highly be appreciated.

Thanx

Sunny




Hello,

I am trying to create a form that loads up text boxes with a number taken from a query. the code i am using is


	Code:
	Dim stDocName As String


    stDocName = "Total Pages by Printer"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

Which opens my query. I then have to enter a date is dd/mm/yyyy format
then the code im using is


	Code:
	Prtr = DLookup("[Mailpieces]", "Total Pages by Printer", "[Printer]= CS1")
 

DoCmd.Close acQuery, "Total Pages by Printer", acSaveNo

But i keep having an error message appear saying that i have cancelled the previous operation. I have tried the code without the close query code but the same error message appears.

Any ideas?




Good morning

I use the following code to update a field

Private Sub Supplier_AfterUpdate()
Dim strFilter As String

strFilter = "SupplierID=" & Me!Supplier
Me!Venue = DLookup("VenueName", "tblVenues", strFilter)
End Sub

But it come back woth an error "Run Time Error 2001 You Canceled The Previouw Operation"

The Data Type Of Venue and Venue Name is Text

Can anyone help please??

Regards
John




In my company, the users use the MS access application. Sometimes, the users get the following error
"You cancelled the previous operation".
After I see such error, then I have to reinstall the GUI and the problem gets fixed.

I dont know if it is the sequence in which they open the form causes the error or something else.

Any idea why it is happening???

Thanks in advance




Hey all... I have three searchable fields in my query ATM if i search the MO, and the job code by themselves they don't error out. But if i try searching the FName field. It says "You have canceled the previous operation? Can someone help me with this




Hi

I have a command button on a form which runs an append query. If the user "cancels" and does not input any data, the following error occurs:

"Error 2001: You canceled the previous operation"

Here is the code:

Dim stDocName As String
stDocName = "PD_new_patient_append"
DoCmd.SetWarnings warningsoff
DoCmd.OpenQuery stDocName, acNormal, acEdit
MsgBox "Please select your patient from the 'Select Existing PD Patient to Update' box."
DoCmd.Requery
Me.PatList.Requery
DoCmd.SetWarnings warningson

I am using Access 2003 for compatibility reasons. Any suggestions are welcome.




I have problem with an update form that has a listbox to select the record to update. The user wants me to ask before overwriting the current record. The code below works in every instance accept when they update a field then click on the list box. If they choose “Cancel” they get an error “2001 – You canceled the previous operation”

The erroe occurs in the Listbox_After update function
Private Sub lstCampaign_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Forms!EventHistory.ShowEvent "lstCampaign_AfterUpdate"
Set rs = Me.Recordset.Clone
rs.FindFirst "[CamId] = '" & Me.lstCampaign & "'"
Me.Bookmark = rs.Bookmark




I have a set of code in a form that I really need to move into a function to use in other places as well. It works perfectly in the form, but when i put it into a module i get the error "you cancelled the previous operation". What it does is calculate interest based on an interest rate that fluxuates over time. I'll paste it up real quick.. but don't make fun of it Why do I get this problem? I changed all the variable names to match is all I did. TIA!





	Code:
	Option Explicit
Option Compare Database

Public Function CalcInterest(grossreceipts As Currency, duedate As Date, datepaid As Date) As Currency

Dim beg_intrate As Long
Dim beg_intrate_begin As Date
Dim beg_intrate_end As Date
Dim end_intrate_begin As Date
Dim end_intrate_end As Date
Dim end_intrate As Long
Dim totalint As String
Dim checkend As Boolean
Dim begint, midint, endint As Currency

beg_intrate_begin = DLookup("[beginning date]", "[interest rates]", "[beginning date]




I'm making a database using Microsoft Acess 2003. When I try to open my query from the database window directly, it opens fine. However, when I use DoCmd.OpenQuery code in a command button, I get run-time error number 2001 saying "You canceled the previous operation."


Here's the sql code for query:


SELECT queBudgetDollarsMonth.Month, queBudgetDollarsMonth.Project_ID, queActualDollarsMonth.WSA, queBudgetDollarsMonth.Description, queBudgetDollarsMonth.[Budgeted Dollars], queActualDollarsMonth.[Actual Dollars]
FROM queActualDollarsMonth INNER JOIN queBudgetDollarsMonth ON queActualDollarsMonth.WSA = queBudgetDollarsMonth.WSA;


Here's the sql code for the two queries queBudgetDollarsMonth and queActualDollarsMonth:


SELECT queWSAActualsDollars.Month, queWSAActualsDollars.Project_ID, queWSAActualsDollars.WSA, queWSAActualsDollars.Description, Sum([queWSAActualsDollars]![Quantity]*[queWSAActualsDollars]![Value TCur]) AS [Actual Dollars]
FROM queWSAActualsDollars
GROUP BY queWSAActualsDollars.Month, queWSAActualsDollars.Project_ID, queWSAActualsDollars.WSA, queWSAActualsDollars.Description, queWSAActualsDollars.[Doc date]
HAVING (((queWSAActualsDollars.[Doc date])>=[forms]![frmParameters2]![txtStart].[Value] And (queWSAActualsDollars.[Doc date])=[forms]![frmParameters2]![txtStart].[Value] And (tblPlan.Date)=[forms]![frmParameters2]![txtStart].[Value] And (queWSAActualsDollars.[Doc date])