RE: User Saving a Record else it deletes
- From: "Carter Wexler" <CarterWexler@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 2 Aug 2005 15:22:02 -0700
Brian,
I tried the code yo gave me and it worked except it only does it on the
before update command which only runs when the user scrolls to another record
or tries to exit. When I placed the code under the save button it doesn't
update the record if the user hits yes, it will only undo the changes if the
user selects no, and the before update procedure will still run if the user
exits or scrolls. is there a way to call the before update procedure within
the save button? I tried placing the subs name to run with the save click
however i got an error.
--
Carter
"Brian" wrote:
> The original data is retained until the form updates, which can be forced by
> forcing a record save, or is automatic when closing the form or moving to a
> new record.
>
> Make a Cancel button (let's call it ButtonCancel) on the form, and make its
> code something like this:
>
> Private ButtonCancel_Click()
> If Not Me.Dirty then Exit Sub 'simply exit if nothing has been changed
> Me.Undo 'undo changes
> End Sub
>
> This at least gives the user an option to cancel input and have the values
> restored to those before the edit. Preventing a form closure or move to a new
> record in error is more difficult; how do you know whether the user wanted to
> save changes or not? You could do this:
>
> 1. Turn off the navigation buttons so that the user cannot simply go to a
> new record. If you do it this way, you will need to create a button to make a
> new record, and be sure to ask the user if he wants to save the current
> record when he clicks ButtonNew also, using the code below.
> 2. Create a Close button and add a confirmation dialog there:
>
> Private Sub ButtonClose_Click()
> If Me.Dirty Then 'only if record has been changed
> If MsgBox("Do you want to save your changes?", vbExclamation + vbYesNo,
> "Save record?") = vbNo Then Me.Undo
> DoCmd.Close
> End Sub
>
> If something has been changed, this asks the user if he wants to save his
> changes. If so, it closes (thus forcing the record to be saved); if not, it
> undoes the changes before closing.
>
> You might also put a confirmation dialog in Form_BeforeUpdate and do a
> Cancel & Undo if the user answers "No." This way, it will always ask, even if
> the user finds another way to move to a new record (such as rolling the mouse
> wheel after changing something).
>
> "Carter Wexler" wrote:
>
> > I want a user editing a record to be able to save the record or else cancel.
> > If the user cancels I want to have the record return to it's original value,
> > before the edit.
> >
> > How do I go about preserving the original record before the edit in case a
> > user does a cancel or closes with the intent of not saving the data. I know
> > access autmatically saves data edited ina form after it's been put in.
> > --
> > Carter
.
- Follow-Ups:
- RE: User Saving a Record else it deletes
- From: Brian
- RE: User Saving a Record else it deletes
- Prev by Date: RE: enter parameter value message when opening form
- Next by Date: RE: enter parameter value message when opening form
- Previous by thread: list box Multi Select propery
- Next by thread: RE: User Saving a Record else it deletes
- Index(es):
Relevant Pages
|