Getting Error 3340 Query ' ' is corrupt while executing queries DoCmd.RunSQL
Since installing the windows update for Office 2010 resolving KB 4484127 I get an error while executing queries which contain a WHERE clause.
For example executing this query:
DoCmd.RunSQL "update users set uname= 'bob' where usercode=1"
Results in this error:
Error number = 3340 Query ' ' is corrupt
The update in question is currently still installed:
How can I successfully run my queries? Should I just uninstall this update?
Summary
This is a known bug caused by the Office updates released on November 12, 2019. The bug affects all versions of Access currently supported by Microsoft (from Access 2010 to 365).
This bug has been fixed.
- If you use a C2R (Click-to-Run) version of Office, use "Update now":
- Access 2010 C2R: Fixed in Build 7243.5000
- Access 2013 C2R: Fixed in Build 5197.1000
- Access 2016 C2R: Fixed in Build 12130.20390
- Access 2019 (v1910): Fixed in Build 12130.20390
- Access 2019 (Volume License): Fixed in Build 10353.20037
- Office 365 Monthly Channel: Fixed in Build 12130.20390
- Office 365 Semi-Annual: Fixed in Build 11328.20480
- Office 365 Semi-Annual Extended: Fixed in Build 10730.20422
- Office 365 Semi-Annual Targeted: Fixed in Build 11929.20494
- If you use an MSI version of Office, install the update matching your Office version. All of these patches have been released on Microsoft Update, so installing all pending Windows Updates should suffice:
- Access 2010 MSI: Fixed in KB4484193
- Access 2013 MSI: Fixed in KB4484186
- Access 2016 MSI: Fixed in KB4484180
Example
Here is a minimal repro example:
- Create a new Access database.
- Create a new, empty table "Table1" with the default ID field and a Long Integer field "myint".
-
Execute the following code in the VBA editor's Immediate Window:
CurrentDb.Execute "UPDATE Table1 SET myint = 1 WHERE myint = 1"
Expected result: The statement successfully finishes.
Actual result with one of the buggy updates installed: Run-time error 3340 occurs ("Query '' is corrupt").
Related links:
- MSDN forum thread
- Official Microsoft page for this bug
Simplest Solution
For my users, waiting nearly a month till December 10 for a fix release from Microsoft is not an option. Nor is uninstalling the offending Microsoft update across several government locked down workstations.
I need to apply a workaround, but am not exactly thrilled with what Microsoft suggested - creating and substituting a query for each table.
The solution is to replace the Table name with a simple (SELECT * FROM Table)
query directly in the UPDATE
command. This does not require creating and saving a ton of additional queries, tables, or functions.
EXAMPLE:
Before:
UPDATE Table1 SET Field1 = "x" WHERE (Field2=1);
After:
UPDATE (SELECT * FROM Table1) SET Field1 = "x" WHERE (Field2=1);
That should be much easier to implement across several databases and applications (and later rollback).