Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / January 2008

Tip: Looking for answers? Try searching our database.

How do I close a form without saving the record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ayo - 10 Jan 2008 15:51 GMT
I am trying to figure out a way to cancel or close a form without saving the
record. I tried: DoCmd.Close acForm, Me.Name, acSaveNo, but a blank record is
still created.
I want to just be able to close the form without creating anything once I
click cancel. How can I accomplish this? Thanks
John W. Vinson - 10 Jan 2008 16:25 GMT
>I am trying to figure out a way to cancel or close a form without saving the
>record. I tried: DoCmd.Close acForm, Me.Name, acSaveNo, but a blank record is
>still created.
> I want to just be able to close the form without creating anything once I
>click cancel. How can I accomplish this? Thanks

acSaveNo refers to saving design changes to the structure of the form, not the
data - often a point of confusion!

You can have your cancel button do

Me.Undo

to restore the contents of the form to what was there when the user started.

            John W. Vinson [MVP]
Ayo - 10 Jan 2008 16:34 GMT
Thank John

> >I am trying to figure out a way to cancel or close a form without saving the
> >record. I tried: DoCmd.Close acForm, Me.Name, acSaveNo, but a blank record is
[quoted text clipped - 12 lines]
>
>              John W. Vinson [MVP]
Ken Sheridan - 10 Jan 2008 16:35 GMT
To both undo and close the form put code along these lines in the button's
Click event procedure:

   Const CANTUNDO = 2046

   On Error Resume Next
   RunCommand acCmdUndo
   Select Case Err.Number
       Case 0
       ' no error
       Case CANTUNDO
       ' anticipated error so do nothing
       Case Else
       ' unanticipated error so inform user
       MsgBox Err.Description, vbExclamation, "Error"
       Exit Sub
   End Select
   
   DoCmd.Close acForm, Me.Name

Ken Sheridan
Stafford, England

> I am trying to figure out a way to cancel or close a form without saving the
> record. I tried: DoCmd.Close acForm, Me.Name, acSaveNo, but a blank record is
> still created.
>  I want to just be able to close the form without creating anything once I
> click cancel. How can I accomplish this? Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.