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.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
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
-
Office gets current release
by
Susan Bradley
2 hours, 9 minutes ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
14 hours, 24 minutes ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
2 hours, 24 minutes ago -
Stop the OneDrive defaults
by
CWBillow
15 hours, 13 minutes ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
1 day, 1 hour ago -
X Suspends Encrypted DMs
by
Alex5723
1 day, 3 hours ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
1 day, 3 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
1 day, 4 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
1 day, 4 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
17 hours, 2 minutes ago -
Enabling Secureboot
by
ITguy
1 day ago -
Windows hosting exposes additional bugs
by
Susan Bradley
1 day, 12 hours ago -
No more rounded corners??
by
CWBillow
1 day, 8 hours ago -
Android 15 and IPV6
by
Win7and10
22 hours, 20 minutes ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
2 days, 1 hour ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
2 days, 3 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
1 day, 22 hours ago -
Windows Update orchestration platform to update all software
by
Alex5723
2 days, 11 hours ago -
May preview updates
by
Susan Bradley
1 day, 22 hours ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
1 day, 14 hours ago -
Just got this pop-up page while browsing
by
Alex5723
2 days, 3 hours ago -
KB5058379 / KB 5061768 Failures
by
crown
2 days ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
1 day, 2 hours ago -
At last – installation of 24H2
by
Botswana12
3 days, 2 hours ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
24 minutes ago -
RyTuneX optimize Windows 10/11 tool
by
Alex5723
3 days, 14 hours ago -
Can I just update from Win11 22H2 to 23H2?
by
Dave Easley
1 day, 13 hours ago -
Limited account permission error related to Windows Update
by
gtd12345
4 days, 4 hours ago -
Another test post
by
gtd12345
4 days, 4 hours ago -
Connect to someone else computer
by
wadeer
5 hours, 44 minutes 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.