Connecting Tech Pros Worldwide Forums | Help | Site Map

Forms and cancelling updates

Samuel Hon
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi All

I'm trying to add an Save/Cancel feature to my forms so that users can
make changes and then reverse them if they so decide.

I've disabled the close button and blocked the Alt-F4 combination so
that the only way to exit the form is to the use the Save/Cancel
buttons

The Save button is straight-forward using DoCmd.Close....

However, the Cancel button is proving to be a bit of a pig. I'm using
ideas from
http://support.microsoft.com/?kbid=197103
but it doesnt mention a Cancel so I'm using

MsgBox("Do you want to save?", vbInformation + vbYesNoCancel, "Save
Record")

The Yes/No is easy to do, but the vbCancel response is not. As one of
the guys says in
http://www.experts-exchange.com/Data..._20810844.html

"if you close the form and hit Cancel and the record is in reality
saved. " ... "in the meantime you will get the message box but if you
hit no you will be stuck with the record that was saved when you hit
cancel."

Does anyone have any ideas on how to implement a decent cancel
rountine?

Thanks in advance

Sam

MGFoster
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Forms and cancelling updates


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Seems easy to me:

const strMSG = "Do you want to save?"

dim intAnswer as integer

intAnswer = MsgBox(strMSG, vbInformation + vbYesNoCancel)

Select Case intAnswer
Case vbYes
DoCmd.RunCommand acCmdSave
Case vbNo
Me.Undo
Case vbCancel
' Don't do anything
End Select


If Cancel is selected - that means cancel the save and cancel close -
in effect - Don't Do Anything.

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQAwuPYechKqOuFEgEQKfegCfWabiRAjNRe2LFoq8qPiQbm bB0cUAoIt5
/S21b/pu47hctjfyqbpPieWA
=OlBD
-----END PGP SIGNATURE-----


Samuel Hon wrote:
[color=blue]
> Hi All
>
> I'm trying to add an Save/Cancel feature to my forms so that users can
> make changes and then reverse them if they so decide.
>
> I've disabled the close button and blocked the Alt-F4 combination so
> that the only way to exit the form is to the use the Save/Cancel
> buttons
>
> The Save button is straight-forward using DoCmd.Close....
>
> However, the Cancel button is proving to be a bit of a pig. I'm using
> ideas from
> http://support.microsoft.com/?kbid=197103
> but it doesnt mention a Cancel so I'm using
>
> MsgBox("Do you want to save?", vbInformation + vbYesNoCancel, "Save
> Record")
>
> The Yes/No is easy to do, but the vbCancel response is not. As one of
> the guys says in
> http://www.experts-exchange.com/Data..._20810844.html
>
> "if you close the form and hit Cancel and the record is in reality
> saved. " ... "in the meantime you will get the message box but if you
> hit no you will be stuck with the record that was saved when you hit
> cancel."
>
> Does anyone have any ideas on how to implement a decent cancel
> rountine?
>
> Thanks in advance
>
> Sam[/color]

Closed Thread


Similar Microsoft Access / VBA bytes