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