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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Save" confirmation message that appers when a close button is clicked

Status
Not open for further replies.

rta

MIS
May 1, 2001
13
0
0
US
Hello All,

I know this is a easy thing to do and I am not that familiar with Access so everything seems hard to me, but I have an Access 97 form that has a close button. I want a message box to appear asking the user if he or she wants to save the record. They can either okay it or cancel it. (This form is linked to a table called all fields.) I have tried to write a macro, utilizing the Save Action, but that only gives me an Okay button on the Message box. Can I still use a macro and just not know what I am doing or should it best if I code it in? I appreciate any feedback you can give me. Thanks.

RTA
 
What about on the Close button this VBA:

if me.dirty then
if msgbox("Save record?",vbyesno) = vbyes then
else
undo
end if
end if

docmd.close

I can't think of the code to undo just yet but bear with me (unless someone else can remember).

Nick
 
Hi! try this in the command button code:

If MsgBox("salvar?", vbYesNoCancel, "Save?") = vbNo Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Else
If MsgBox("salvar?", vbYesNoCancel, "Save?") = vbcancel Then
exit sub
End If
End If

docmd.close (docmd.quit)

when you use the docmd.close it simply quits the form! however if you use the docmd.quit it exits from the aplication itself! it's your call!

hope it works!
Skep :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top