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 / Forms / September 2006

Tip: Looking for answers? Try searching our database.

Save and exit

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt Dawson - 04 Sep 2006 15:35 GMT
Is it possible to create a save and exit button within VBA?
Rick Brandt - 04 Sep 2006 15:39 GMT
> Is it possible to create a save and exit button within VBA?

Save what exactly and exit what exactly?

To save the current record on the current form and then exit Access...

Me.Dirty = False
DoCmd.Quit

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

J. Goddard - 04 Sep 2006 16:18 GMT
What do you mean by "create and save" the button?  If you mean that you
are modifying a form using VBA, the answer is "Yes" - but it is not
quick and easy.  Why not create an invisible button in form design, and
then make it visible as needed?

John

> Is it possible to create a save and exit button within VBA?
Matt Dawson - 05 Sep 2006 09:37 GMT
Sorry I didn't make myself clear.
I meant a save and exit command button to simply save the record and exit
the form.

> What do you mean by "create and save" the button?  If you mean that you
> are modifying a form using VBA, the answer is "Yes" - but it is not
[quoted text clipped - 4 lines]
>
> > Is it possible to create a save and exit button within VBA?
Rick Brandt - 05 Sep 2006 12:14 GMT
> Sorry I didn't make myself clear.
> I meant a save and exit command button to simply save the record and exit
> the form.

Records are automatically saved when you close a form.  If you feel you really
need a button to close the form then you *should* actually save the record
explicitly in that code due to a bug in Access.

Me.Dirty = False
DoCmd.Close acForm, Me.Name

The Bug:  If you close a form normally and there is an unsaved edit in the form
that does not comprise a legal record (required field missing for example) you
will get an error and warning message indicating that the dirty record cannot be
saved.

If you close the form with your own code, then that message is not shown.  The
illegal record is discarded without the user being notified.  By saving the
record first in your code you will be notified if the record cannot be saved for
some reason.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

 
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



©2008 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.