Wrox Programmer Forums
|
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
 
Old June 3rd, 2004, 03:04 PM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.



 
Old June 3rd, 2004, 03:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
 
Old June 3rd, 2004, 03:53 PM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old June 3rd, 2004, 03:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
 
Old June 3rd, 2004, 04:00 PM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, the light bulb is not coming on here. How do I open the form UNbound

- cq

 
Old June 3rd, 2004, 06:02 PM
Authorized User
 
Join Date: May 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How about just changing the properties of the form?

On the tab for Data:
Change "Allow Edits" from "Yes" to "No"
 
Old June 3rd, 2004, 08:24 PM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old June 4th, 2004, 06:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
 
Old June 4th, 2004, 08:14 AM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I knew it could be done. Thank you, that is what I was looking for!

:)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Close all MdiChield form from open one form/Button salman .NET Framework 2.0 6 December 10th, 2007 03:21 AM
Close all MdiChield form from open one form salman .NET Framework 1.x 0 November 8th, 2007 12:32 AM
How To Close One Form And Show Another form Israr VS.NET 2002/2003 1 December 7th, 2004 12:30 PM
How Do I Close a Form When I Move to Another Form. flyingfox VB.NET 2002/2003 Basics 3 December 29th, 2003 08:56 AM
Cannot close the Form jkalinina C# 3 October 31st, 2003 05:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.