Ms Access Error 201 You Cancelled The Previous Operation
Custom Search UtterAccess Forums>Microsoft® Access>Access Errors + Error Handling "You canceled the previous operation" Forum HomeSearchHelpUA Messages|-- UtterAccess.com NewsAccess Knowledge Center|-- Access Code Archive|-- Access Knowledgebase / FAQ|-- Access TutorialsMicrosoft® Access|-- Local Access User Groups (AUGs)|-- Interface Design|-- Access Q and A|-- Access Tables + Relationships|-- Access Queries|-- Access Forms|-- Access Reports|-- Access Macros|-- Access Modules|-- Access Date + Time|-- Access Errors + Error Handling|-- Access Built-in Functions|-- Access Searching + Data Mining|-- Access Records|-- Access Security|-- Access Automation|-- Access Database Container|-- Tool bars, Menu bars + Ribbon|-- Access Services (Web Databases)|-- Access Data Access Pages (Deprecated)|-- Access Data Projects - ADP|-- Access Runtime, Packaging & DeploymentAnd More...|-- Microsoft SQL Server|-- SQL Server Reporting Services|-- Microsoft SharePoint|-- Microsoft Internet Explorer|-- Visual Basic 6 and Earlier|-- Visual Basic 2003 and Later|-- ASP and VBScript|-- Web Development|-- PHP, Perl, MySQL and Postgres|-- Other Database Engines|-- BI Tools and Applications|-- JAVA and C#|-- GraphicsMicrosoft® Office|-- Microsoft Excel|-- Microsoft Excel FAQs|-- Microsoft Word|-- Microsoft Outlook|-- Microsoft PowerPoint|-- Microsoft FrontPage/Exp. Web|-- Other Microsoft ProductsPC|-- Network Issues|-- Q & A - Hardware|-- Q & A - Software|-- Q & A - Other PC|-- Virus + Security DiscussionUtterAccess Odds and Ends|-- General Chat|-- Q & A - UtterAccess.com Forums|-- Q & A - Access Wiki Options comalleyView Member Profile Sep 17 2004, 09:06 AM Post#1Posts: 2Joined: 24-March 04
your question and get tips & solutions from a community of 418,595 IT Pros & Developers. It's quick & easy. How to cancel a close event 100+ P: 201 reginaldmerritt I want to check the form for missing data when the form is closed. I've done this by adding a message on the Form_Unload event, the user http://www.utteraccess.com/forum/you-canceled-previous-o-t543123.html can either choose to use defult values for missing data or cancel the close event. From searching online i have found the the following should allow cancelation of the close event. Expand|Select|Wrap|Line Numbers DoCmd.CancelEvent However, this doesn't if the close event is via VBA code rather than the forms https://bytes.com/topic/access/answers/909549-how-cancel-close-event inbuilt close button. For example, the following code does not work: Expand|Select|Wrap|Line Numbers PrivateSubOwnCloseButton_Click() DoCmd.Close EndSub PrivateSubForm_Unload(CancelAsInteger) Missinginfomessage=MsgBox("InformationMissing"&vbNewLine&_ "AcceptDefultValues",vbOKCancel) IfMissinginfomessage=vbOKThen 'setdefultvaluesandclose EndIf IfMissinginfomessage=vbCancelThen DoCmd.CancelEvent EndIf EndSub If the OwnCloseButton is clicked the cancel event cancels the DoCmd.Close statment and i get a run time error. Run-time Error '2001' You canceled the previous operation Does anyone know how i can cancel the close event without getting this error? Many Thanks. Mar 7 '11 #1 Post Reply Share this Question 9 Replies Expert Mod 100+ P: 2,316 TheSmileyCoder You need to modify the click event to handle the error. Seen from a logic point of view, its actually desirable that when we request an action, that if it fails we get informed. Most good code will inform somehow, if it fails. Anyways, adding error handling: Expand|Select|Wrap|Line Numbers PrivateSubOwnCloseButton_Click() OnErrorGotoErr_Handler DoCmd.Close ExitSub Err_Handler: IfErr.Number=2001Then 'Don'tdoanything,sincegettingthiserrorjustmeanstheformvalidationfailed Else
be down. Please try the request again. Your cache administrator is webmaster. Generated Thu, 20 Oct 2016 17:11:35 GMT by s_nt6 (squid/3.5.20)