 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 3rd, 2004, 03:04 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Close form without saving
I have two buttons on a form, Save and Close. The Save button will close the form and save any changes. I don't the Close button to do anything but close the form, but it keeps saving changes just like the Save button. What do I need to do?
And yes I've tried:
DoCmd.Close, "", acSaveNo ... it doesn't work.
|
|

June 3rd, 2004, 03:43 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
One option is to open the form UNbound to begin with. If you close the form, then nothing is saved anyway. If you want to save the data, THEN you write code in your save button to purposely save the data and close the form.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

June 3rd, 2004, 03:53 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
That works if nothing has been changed, but I don't want to save ANY changes that someone may have made to the data while viewing the record.
Is there some object or function that I can disable?
- cq
|
|

June 3rd, 2004, 03:55 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
No, if you open a form UNbound, nothing will be changed if you just close the form. Not even if you typed something in every field.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

June 3rd, 2004, 04:00 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok, the light bulb is not coming on here. How do I open the form UNbound
- cq
|
|

June 3rd, 2004, 06:02 PM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How about just changing the properties of the form?
On the tab for Data:
Change "Allow Edits" from "Yes" to "No"
|
|

June 3rd, 2004, 08:24 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
That defeats the purpose of the form. The "Close" button is suppose the close the form, nothing else. Even if someone mistakenly fat fingers a field or hits the scroll button on their mouse. If they don't click the "Save" button the record should not change.
Is there some default feature in Access that is forcing the record to be saved if any edit is made?
-c
|
|

June 4th, 2004, 06:48 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
The way Access works is that if you open a BOUND form and you make any changes to any field in the data, as soon as you leave the record (either by scrolling to the next one or closing the form), the record is saved automatically.
Here are two ways to avoid it. You can either open the form UNbound and then populate the data from your table (in which case just closing the form will not save data, you have to write code to save data); or you can open the form BOUND like you're doing, but on your ON CLICK event of the CLOSE button, you can place a
Me.Undo
command just prior to closing the form. That should undo the typing of the record.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

June 4th, 2004, 08:14 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I knew it could be done. Thank you, that is what I was looking for!
:)
|
|
 |