RE: User Saving a Record else it deletes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • RE: User Saving a Record else it deletes
    ... The code I posted simply does not undo if the user clicks no, ... > or tries to exit. ... >> Make a Cancel button on the form, ... >> End Sub ...
    (microsoft.public.access.forms)
  • Re: Record Validation Strategy
    ... Private Sub cmdExit_Click ... I would like to provide an exit button, ... I could Cancel, but I get an unwanted "Close Action cancelled" message. ... Dim intResponse As Integer ...
    (microsoft.public.access.forms)
  • Re: stop code sending cancelled email
    ... close the email without sending The cancel triggers error ... "Alex Dybenko" wrote: ... Private Sub Command5_Click ... Exit Sub ...
    (microsoft.public.access.modulesdaovba)
  • Re: "Variable Not Defined"
    ... Cancel -- if set to true on Exit, ... > 'On Error GoTo ErrHandler ... > Exit Sub ...
    (microsoft.public.access.formscoding)
  • Re: More efficient code for If Else data validation rule?
    ... cboFavoriteColor. ... if i'm going to cancel an event, i normally do it before taking ... Private Sub cboFavoriteColor_BeforeUpdate ...
    (microsoft.public.access.formscoding)