I would like to capture a NO user response from the “CAN’T APPEND RECORDS…RUN QUERY?” (I paraphrase) error that ACCESS gives when an append query output violates the destination table validation rules. I Know I have seen (and at times captured) a 3059 OPERATION CANCELLED BY USER pop-up but now that I have the code written I can’t trigger the error. Is there some property that must be set to capture this response? Thanks.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Trapping ‘Operation Cancelled’ during Append Query (2000)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Trapping ‘Operation Cancelled’ during Append Query (2000)
- This topic has 6 replies, 3 voices, and was last updated 21 years, 1 month ago.
AuthorTopicWSBillHumphries
AskWoody LoungerApril 9, 2004 at 3:42 am #403468Viewing 3 reply threadsAuthorReplies-
WSMarkD
AskWoody LoungerApril 9, 2004 at 3:01 pm #812601If you’re referring to the error msg like the one illustrated, AFAIK this type of error cannot be trapped. See this MSKB article:
ACC2000: Cannot Trap Import Errors in Visual Basic for Applications
Article states in part: “The same rules that apply to manual data entry also apply to methods for importing data when using Visual Basic for Applications. Therefore, any violations of rules, such as referential integrity, validation rules, or the Required property, will result in an incomplete import. In Microsoft Access 2000, no trappable error is generated and if the procedure disables system messages by using the SetWarnings statement, there is no indication that any problem occurred. ” Though not exactly same situation, the same principle is applicable to running action queries, whether in UI or via VBA using DoCmd methods, you cannot trap this type of error.
When appending, updating, or deleting records programatically the recommended approach is to use the ADO Connection Execute method, or DAO equivalent. Both the ADO Connection object and the DAO Database & QueryDef objects have a RecordsAffected property that can be used to determine how many records were affected by the query. In addition, both the ADO Connection object and DAO DBEngine object have an Errors collection that you can loop thru to determine what specific error(s) occurred when trying to execute the query or SQL statement. The DAO errors tend to be more useful; when an ADO action query fails to execute due to key violations, etc, you usually get this standard error msg:
Invalid SQL statement; expected ‘DELETE’, ‘INSERT’, ‘PROCEDURE’, ‘SELECT’, or ‘UPDATE’.
As noted in MSKB article, disabling standard warnings with SetWarnings method is NOT a good idea, you have no way of determining if action query succeeded, failed, or only partially succeeded. Recommend use ADO or DAO Execute method for append, update, and delete queries, with appropriate error handling enabled.
HTH
-
WSBillHumphries
AskWoody LoungerApril 14, 2004 at 2:38 am #814312Thanks for your response. I got the following technique for executing an action query to work exactly as desired (I wrapped the code in a boolean function) as shown below. A couple of notes:
1)Using Docmd.openquery with a NO response to the “violations detected – continue?” dialog DOES sometimes raise a 3059 ‘user cancelled operation’ error and I remember at least once being able to trap it. Don’t know under what circumstances however and couldn’t reproduce it.
2) Controls on forms coded for query criteria did not seem to work using this technique. I had to code a parameter and build its value in VBA, as shown below.
3) DBFAILONERROR option is required or error will not be trapped.
4)Gratifyingly, the ERROR object returns exactly what error took place (ie what column failed).
:‘Calling code:
Set Qdf = CurrentDb.QueryDefs(“qryEstA_Cost_100A”)
Qdf.Parameters(“ctlsub”) = Me.ctlSub
If Not fDaoQry(Qdf) Then Exit FunctionFunction:
Function fDaoQry(Qdf As DAO.QueryDef) As Boolean
””””””””””””””””””””””””
Dim ErrNum, ErrDsc
”””””””””
On Error Resume Next
Qdf.Execute dbFailOnError
ErrNum = Err
ErrDsc = Err.Description
On Error GoTo 0
”””””””’
If ErrNum 0 Then
MsgBox “Error ” & ErrNum & ” executing ” & Qdf.Name & “: ” & ErrDsc, vbCritical
End If
””””’
fDaoQry = (ErrNum = 0)
End Function
;comments. -
WSBillHumphries
AskWoody LoungerApril 14, 2004 at 2:38 am #814313Thanks for your response. I got the following technique for executing an action query to work exactly as desired (I wrapped the code in a boolean function) as shown below. A couple of notes:
1)Using Docmd.openquery with a NO response to the “violations detected – continue?” dialog DOES sometimes raise a 3059 ‘user cancelled operation’ error and I remember at least once being able to trap it. Don’t know under what circumstances however and couldn’t reproduce it.
2) Controls on forms coded for query criteria did not seem to work using this technique. I had to code a parameter and build its value in VBA, as shown below.
3) DBFAILONERROR option is required or error will not be trapped.
4)Gratifyingly, the ERROR object returns exactly what error took place (ie what column failed).
:‘Calling code:
Set Qdf = CurrentDb.QueryDefs(“qryEstA_Cost_100A”)
Qdf.Parameters(“ctlsub”) = Me.ctlSub
If Not fDaoQry(Qdf) Then Exit FunctionFunction:
Function fDaoQry(Qdf As DAO.QueryDef) As Boolean
””””””””””””””””””””””””
Dim ErrNum, ErrDsc
”””””””””
On Error Resume Next
Qdf.Execute dbFailOnError
ErrNum = Err
ErrDsc = Err.Description
On Error GoTo 0
”””””””’
If ErrNum 0 Then
MsgBox “Error ” & ErrNum & ” executing ” & Qdf.Name & “: ” & ErrDsc, vbCritical
End If
””””’
fDaoQry = (ErrNum = 0)
End Function
;comments.
-
WSMarkD
AskWoody LoungerApril 9, 2004 at 3:01 pm #812602If you’re referring to the error msg like the one illustrated, AFAIK this type of error cannot be trapped. See this MSKB article:
ACC2000: Cannot Trap Import Errors in Visual Basic for Applications
Article states in part: “The same rules that apply to manual data entry also apply to methods for importing data when using Visual Basic for Applications. Therefore, any violations of rules, such as referential integrity, validation rules, or the Required property, will result in an incomplete import. In Microsoft Access 2000, no trappable error is generated and if the procedure disables system messages by using the SetWarnings statement, there is no indication that any problem occurred. ” Though not exactly same situation, the same principle is applicable to running action queries, whether in UI or via VBA using DoCmd methods, you cannot trap this type of error.
When appending, updating, or deleting records programatically the recommended approach is to use the ADO Connection Execute method, or DAO equivalent. Both the ADO Connection object and the DAO Database & QueryDef objects have a RecordsAffected property that can be used to determine how many records were affected by the query. In addition, both the ADO Connection object and DAO DBEngine object have an Errors collection that you can loop thru to determine what specific error(s) occurred when trying to execute the query or SQL statement. The DAO errors tend to be more useful; when an ADO action query fails to execute due to key violations, etc, you usually get this standard error msg:
Invalid SQL statement; expected ‘DELETE’, ‘INSERT’, ‘PROCEDURE’, ‘SELECT’, or ‘UPDATE’.
As noted in MSKB article, disabling standard warnings with SetWarnings method is NOT a good idea, you have no way of determining if action query succeeded, failed, or only partially succeeded. Recommend use ADO or DAO Execute method for append, update, and delete queries, with appropriate error handling enabled.
HTH
WBell
AskWoody_MVPApril 10, 2004 at 7:49 pm #812983Adding to Mark’s comments, there is a partial work-around for import errors. When an import error occurs, in most circumstances Access creates an “Import Errors” table, and writes records that describes the problem to that table. If you are automating an import process, you can check for the existance of that table, and if it exists, you can then warn the user. That doesn’t solve all the problems, but it does provide some help.
WBell
AskWoody_MVPApril 10, 2004 at 7:49 pm #812984Adding to Mark’s comments, there is a partial work-around for import errors. When an import error occurs, in most circumstances Access creates an “Import Errors” table, and writes records that describes the problem to that table. If you are automating an import process, you can check for the existance of that table, and if it exists, you can then warn the user. That doesn’t solve all the problems, but it does provide some help.
Viewing 3 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Flash Drive Eject Error for Still In Use
by
J9438
21 minutes ago -
Windows 11 Insider Preview build 27863 released to Canary
by
joep517
16 hours, 24 minutes ago -
Windows 11 Insider Preview build 26120.4161 (24H2) released to BETA
by
joep517
16 hours, 26 minutes ago -
AI model turns to blackmail when engineers try to take it offline
by
Cybertooth
9 hours, 9 minutes ago -
Migrate off MS365 to Apple Products
by
dmt_3904
36 minutes ago -
Login screen icon
by
CWBillow
7 hours, 50 minutes ago -
AI coming to everything
by
Susan Bradley
16 hours, 35 minutes ago -
Mozilla : Pocket shuts down July 8, 2025, Fakespot shuts down on July 1, 2025
by
Alex5723
1 day, 8 hours ago -
No Screen TurnOff???
by
CWBillow
1 day, 8 hours ago -
Identify a dynamic range to then be used in another formula
by
BigDaddy07
1 day, 8 hours ago -
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
1 day, 20 hours ago -
How well does your browser block trackers?
by
n0ads
1 day, 6 hours ago -
You can’t handle me
by
Susan Bradley
6 hours, 51 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
23 hours, 30 minutes ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
2 days, 7 hours ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
1 day, 11 hours ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
2 days, 8 hours ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
2 days, 8 hours ago -
Lumma malware takedown
by
EyesOnWindows
1 day, 20 hours ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
2 days, 17 hours ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
2 days, 17 hours ago -
Meet Gemini in Chrome
by
Alex5723
2 days, 21 hours ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
2 days, 21 hours ago -
Trump signs Take It Down Act
by
Alex5723
3 days, 5 hours ago -
Do you have a maintenance window?
by
Susan Bradley
1 day, 10 hours ago -
Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms
by
Nibbled To Death By Ducks
2 days, 7 hours ago -
Cox Communications and Charter Communications to merge
by
not so anon
3 days, 8 hours ago -
Help with WD usb driver on Windows 11
by
Tex265
19 hours, 51 minutes ago -
hibernate activation
by
e_belmont
3 days, 17 hours ago -
Red Hat Enterprise Linux 10 with AI assistant
by
Alex5723
3 days, 21 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.