Solved

don't save record and Close form

Posted on 2014-12-12
5
273 Views
Last Modified: 2014-12-12
Hello,

I have a form and if  the data entry person decides not to save the record and closes the form I would like to

Not save the record
close the form
clear any and all errors



I only have the close button (the X on the top of form) and no other buttons...they would click that button to close if they don't want to save the record
0
Comment
Question by:Ernest Grogg
5 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40496596
you need a command button to do this (cmdCancel)

private sub cmdCancel_click()

me.undo

docmd.close acform,me.name

end sub
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40496611
Forget it.
While it is not impossible to do what you've asked, it is hard enough, and error prone enough, that you do not want to go there.  Good data entry forms are always a lot of work to create.  MS has created all sorts of nice wizards that create forms backed by live data  -- which create, change or alter data willy-nilly based on the actions of the user.  Not Good

Proper data entry forms have mechanisms that allow users to prepare their data for entry and that then require a deliberate action to make it so.  These are a lot more work to create than the simple wizard forms -- but getting good, clean data into the database is important enough to make it worth the trouble.

Maybe someone else will disagree.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40496823
I agree with Nick and Rey.

Although I leave the X and close options available on most of my forms, I disable those properties on my data entry forms and place Cancel and Save buttons in the form footer.  This way, the only way for a user to close a data entry form is to either cancel, or meet all of the requirements for saving the record.
0
 

Author Comment

by:Ernest Grogg
ID: 40496985
I agreed too put the button on the footer....thanks for the tip
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40497013
Be warned.

There remain many ways for this to go wrong.
The app crashing
The computer rebooting/power failing/crashing
Network intermittency
Task manager use in killing the app.
Code that switches the focus to another app or form
Other things that don't come to the top of my mind at the moment.

The only certain way to ensure that only data you want entered into the tables is to do it through code yourself as the developer.  Everything else is prone to some level of -- perhaps acceptable in your application -- error
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now