PC Review


Reply
Thread Tools Rate Thread

record saves no matter what

 
 
Dave Cullen
Guest
Posts: n/a
 
      21st Apr 2006
I want to allow a user to close a form without saving any changes that
might have been made. Basically an "Abort" function.

I put a Close button on the form. The code behind this button defaults
to

DoCmd.Close

I added arguments to this by changing it to

Call DoCmd.Close(, , acSaveNo)

It doesn't work. No matter what I do Access updates the record with
whatever changes are made in the form.

Help please.
 
Reply With Quote
 
 
 
 
Wayne Morgan
Guest
Posts: n/a
 
      21st Apr 2006
The acSaveNo is to not save design changes. It is possible to open a form in
design view and manipulate it using code. When you close it, you can then
save or not save those design changes. To not save record edits, you need to
Undo those edits before closing the form. This can be done by pressing the
Esc key twice. To do the same thing in code, the command is

Me.Undo
DoCmd.Close acForm, Me.Name

If you don't specify what to close, then the item with the focus will be
closed. Since you just clicked the button on the form to do this, it will
probably be the form with the button. However, if you have another form open
with code in its timer event that may cause it to receive the focus, you may
have a problem if you don't specify what to close.

--
Wayne Morgan
MS Access MVP


"Dave Cullen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I want to allow a user to close a form without saving any changes that
> might have been made. Basically an "Abort" function.
>
> I put a Close button on the form. The code behind this button defaults
> to
>
> DoCmd.Close
>
> I added arguments to this by changing it to
>
> Call DoCmd.Close(, , acSaveNo)
>
> It doesn't work. No matter what I do Access updates the record with
> whatever changes are made in the form.
>
> Help please.



 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      21st Apr 2006
Since the user may or may not want to save the changes, I would recommend a
message box to give the user the option:

If Me.Dirty and MsgBox("Save Changes to Current Record", vbQuestion +
vbYesNo, _
"Record Has Not Been Updated") = vbYes Then
Me.Undo
End If
DoCmd.Close acForm, Me.Name


"Wayne Morgan" wrote:

> The acSaveNo is to not save design changes. It is possible to open a form in
> design view and manipulate it using code. When you close it, you can then
> save or not save those design changes. To not save record edits, you need to
> Undo those edits before closing the form. This can be done by pressing the
> Esc key twice. To do the same thing in code, the command is
>
> Me.Undo
> DoCmd.Close acForm, Me.Name
>
> If you don't specify what to close, then the item with the focus will be
> closed. Since you just clicked the button on the form to do this, it will
> probably be the form with the button. However, if you have another form open
> with code in its timer event that may cause it to receive the focus, you may
> have a problem if you don't specify what to close.
>
> --
> Wayne Morgan
> MS Access MVP
>
>
> "Dave Cullen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I want to allow a user to close a form without saving any changes that
> > might have been made. Basically an "Abort" function.
> >
> > I put a Close button on the form. The code behind this button defaults
> > to
> >
> > DoCmd.Close
> >
> > I added arguments to this by changing it to
> >
> > Call DoCmd.Close(, , acSaveNo)
> >
> > It doesn't work. No matter what I do Access updates the record with
> > whatever changes are made in the form.
> >
> > Help please.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error when press "Save Record" but not when record saves itself automatically AndyCotgreave Microsoft Access 3 26th Jan 2006 03:08 PM
How can I setup Access 2003 to prompt me before it saves a record =?Utf-8?B?dGNkb3Jpb3Q=?= Microsoft Access 7 20th Nov 2004 08:25 PM
sometimes record saves,sometimes not Brigitte P Microsoft Access 0 25th Aug 2004 12:15 AM
Record to stay in one spot not matter how rest is sorted? StargateFanFromWork Microsoft Excel Programming 1 25th Jun 2004 06:06 PM
Subform saves spurious data on navigating to next record Hemil Microsoft Access 0 22nd Jun 2004 10:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:55 PM.