Skip to content
Auscultby NBIT
EN
Free diagnostic

Access error reference

Access error 2001: you canceled the previous operation

Nobody canceled anything, yet Access says “You canceled the previous operation”. The message is misleading: an operation failed — most often a `DLookup`, a `DCount` or a filter — and Access reports it as interrupted.

The message

Microsoft Visual Basic box: “Run-time error '2001': You canceled the previous operation.”
The real error box, captured in Access for Microsoft 365 in English: the form's filter refers to a deleted field, Access asks for its value, the user clicks “Cancel”.

Run-time error '2001': You canceled the previous operation.

English Access

On a French Access: « Opération annulée. » (Microsoft 365) In a macro, it appears in the “Action Failed” box, under the action that failed (SetLocalVar, RunCode…).

Where it shows up

Mostly on a line that calls a domain aggregate function: DLookup, DCount, DSum, DMax, DFirst… Also on Me.Filter followed by Me.FilterOn = True, DoCmd.ApplyFilter, and in the embedded macros of buttons that compute a value with DLookUp before opening a form or checking a password.

Common causes

  • a wrong field name in the first argument: DLookup("[Unit Price]", "Products", …) while the field is called UnitPrice;
  • a malformed criteria in the third argument: an empty control ("[CustomerID]="), text without quotes, a control name pasted inside the quotes;
  • a domain (second argument) that fails: a source query that is itself in error, or that expects a parameter;
  • a filter that refers to a field missing from the form's record source;
  • more rarely, a real interruption: a form event that cancels (Cancel = True) or Ctrl+Break during execution.

Measured on a French Access for Microsoft 365: a DLookup that refers to a missing field stops there on error 2471 (the expression you entered as a query parameter produced an error), and an empty criteria on error 3075. Error 2001 remains the message of a cancelled prompt: Access asks for the value of a name it does not know, and the user clicks “Cancel” — for example when a form's filter refers to a deleted field and the code changes the sort order.

How to reproduce and check it

  1. Click “Debug”: spot the domain function or the filter on the highlighted line.
  2. Test each argument in the Immediate window (Ctrl+G): ? DCount("*", "Products") checks the domain, then add the field, then the criteria.
  3. Print the criteria built (Debug.Print strWhere): an empty value or a missing quote stands out.

How to fix it

Fix the field or domain name, put names in brackets, and build the criteria with the value outside the quotes, in the right format for its type. Test the control before the call: an empty criteria is the most common cause.

What Auscult reports

The diagnostic files 2001 among cancellation errors, like 2501: they are counted separately as “to confirm” and do not weigh on the score, because a cancellation can come from the application itself.

The Access error reference, code by code

Frequently asked questions

I didn't cancel anything: why this message?

Because domain aggregate functions (DLookup, DCount…) report their failure under this number. The message talks about canceling; the cause is almost always a wrong argument.

Should DLookup be replaced with queries?

Not necessarily. A well-written DLookup works. Fix its arguments first; replace it with a recordset only if it is called hundreds of times in a loop, for speed.

Where are the other errors in your application hiding?

The diagnostic runs on your computer, on a copy of the application, without sending the data in your tables. The health grade and the summary are free.