Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exit a form without saving

Status
Not open for further replies.

farcanal

IS-IT--Management
Jun 29, 2006
9
ZA
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
 
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
 
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...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top