INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Exit a form without saving

Exit a form without saving

(OP)
Hi
I want to ask the user if they want to exit without saving a form (after making changes to a record). I can get the code to work if I use 'Form_Unload' and close the form using DoCmd.Close. But when I step thru the records using the nav. bar this doesn't work.
I have also tried ...
Private Sub Form_BeforeUpdate(Cancel As Integer)
    If MsgBox("Exit without Saving?", vbYesNo) = vbYes Then
        Exit Sub
    Else
        Cancel = True
    End If
End Sub
This seems to detect a change made on the form and offers the prompt on closing/navigating...but the change made by the user is not ignored .. it is still saved?

Any ideas? - thanks

RE: Exit a form without saving

    If MsgBox("Exit without Saving?", vbYesNo) = vbYes Then
        Cancel = True
    End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886

RE: Exit a form without saving

(OP)
Thanks PH - now it doesn't move to the next record.
The MsgBox is displayed - when I select 'Yes' it stays on the record, if I select "no" it moves but the data I have changed is still saved...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close