Closing Forms without saving

wjoc1

Registered User.
Local time
Today, 21:55
Joined
Jul 25, 2002
Messages
117
I have data entry forms but I want to include a button whcih allows a user to close the form but not save any current information that they may have entered in the form. As default Access saves the record to the table when the form is closed.

At present i have the following code in the button:

DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close

However the 'undo' isn't entirely satisfactory. Is there any other way around this?

Also should I change the DoMenuItem to RunCommand. According to the help files the DoMenuItem has been scrapped since '97 but that's what Access 2000 put's in itself?????

Liam
 
would delete record do the job?
 
Try this in your forms BeforeUpdate event...

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_Err

Beep
If MsgBox("The current record has been altered!" & Chr(13) & Chr(13) & "Do you wish to save your changes?" & Chr(13) & Chr(13) & "Click Yes to Save or No to Discard changes.", vbQuestion + vbYesNo, "Save Current Record Change?") = vbYes Then 'do nothing
Else
DoCmd.RunCommand acCmdUndo
End If

Form_BeforeUpdate_Exit:
Exit Sub

Form_BeforeUpdate_Err:
MsgBox Error$
Resume Form_BeforeUpdate_Exit

End Sub

'HTH
 

Users who are viewing this thread

Back
Top Bottom