Charlotte Foust
cfoust at infostatsystems.com
Wed Sep 5 10:21:48 CDT 2007
All you're doing is cancelling the update, not cancelling the close of the form. Use the Unload event of the form to cancel a close. Set a flag in BeforeUpdate and then test that flag in Unload to see whether the form should be allowed to close. Charlotte Foust -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of rusty.hammond at cpiqpc.com Sent: Wednesday, September 05, 2007 6:41 AM To: accessd at databaseadvisors.com Subject: Re: [AccessD] Cancel the closing of a form Steve, When I put that code in the BeforeUpdate the form still closes. -----Original Message----- From: Steve Schapel [mailto:miscellany at mvps.org] Sent: Wednesday, September 05, 2007 12:21 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Cancel the closing of a form Rusty, Simply use the Before Update event of the form. If the current record has not changed, the Before Update event will not occur. If the current record has changed, the code that fires could be along these lines: Dim answer As Integer answer = MsgBox("Save changes?", vbYesNoCancel) If answer = vbNo Then Me.Undo ElseIf answer = vbCancel Then Cancel = True End If Regards Steve rusty.hammond at cpiqpc.com wrote: > I have a form that when I close it either from a close button on the > form or > from the built in close button, I want to test if the current record > has changed. If it has changed, I want to prompt the user to either > Save the record and go ahead and close the form, not save the record > and close the form, or not save the record and not close the form via > a YesNoCancel message box. > > If I use the close event of the form testing for me.dirty doesn't work > because the record is already saved. > > Is there any way to do this? -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com ********************************************************************** WARNING: All e-mail sent to and from this address will be received, scanned or otherwise recorded by the CPI Qualified Plan Consultants, Inc. corporate e-mail system and is subject to archival, monitoring or review by, and/or disclosure to, someone other than the recipient. ********************************************************************** -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com