The Close action was canceled. Run Time error '2501'

Local time
Today, 06:54
Joined
Oct 7, 2016
Messages
43
Dear Sir,

In MsAccess 2007 I have two Forms, Form1 and Form2

The code written :-

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.Close acForm, "Form1"
stDocName = "Form2"
DoCmd.OpenForm stDocName, , , stLinkCriteria


I have also used the following syntax :-
(1) before above code [ Docmd.SetWarning False ] and after Code [Docmd.SetWarning True]
(2) Error Handler


While Closing Form1 and Opening Form2 , I am getting an Error The Close action was canceled.
Run Time error '2501'


Note : In the above mentioned process I do not want to Save Form1 and Form2.

Kindly solve my issue.
 
can you open Form2 first before you close Form1?
meaning change the order of your code.
 
can you open Form2 first before you close Form1?
meaning change the order of your code.

As Suggested , I have changed the code , still the same error received.

Syntax as follows :

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form2"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "Form1"
 
do you have other codes inside form1 coz i tried it.
 

Attachments

Is that because you are trying to close a form in the close event?
 
Gasman is correct, you are doubly-closing the form.
see this change on the airline_mast form.
 

Attachments

Users who are viewing this thread

Back
Top Bottom