Connecting Tech Pros Worldwide Help | Site Map

Ask before saving record

Alan Oats
Guest
 
Posts: n/a
#1: Nov 13 '05
I want to use this code from http://www.mvps.org/access/forms/frm0027.htm


Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "@Do you wish to save the changes?"
strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo

'For Access 95, use DoMenuItem instead
'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
End Sub


For me in Access 2003 "German" this does not function.

the code breaks and reports that this function is not available at the
moment.

Thanks Alan


Danny J. Lesandrini
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Ask before saving record


Try replacing the line ...
DoCmd.RunCommand acCmdUndo

With
Cancel = True

--

Danny J. Lesandrini
dlesandrini@hotmail.com
http://amazecreations.com/datafast/



"Alan Oats" <chrazer@gmail.com> wrote in message news:433fef06_3@news.bluewin.ch...[color=blue]
>I want to use this code from http://www.mvps.org/access/forms/frm0027.htm
>
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> Dim strMsg As String
> strMsg = "Data has changed."
> strMsg = strMsg & "@Do you wish to save the changes?"
> strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
> If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
> 'do nothing
> Else
> DoCmd.RunCommand acCmdUndo
>
> 'For Access 95, use DoMenuItem instead
> 'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
> End If
> End Sub
>
>
> For me in Access 2003 "German" this does not function.
>
> the code breaks and reports that this function is not available at the moment.
>
> Thanks Alan
>[/color]


Alan Oats
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Ask before saving record


That works partially. It stops the record update. It does not however
return the changed records to its original format. The only way is by using
the escape key. It is an improvement but adds a little complexity to the
user interface.

Thankyou for the help I am at least one step further with this tip.



Alan


"Danny J. Lesandrini" <dlesandrini@hotmail.com> schrieb im Newsbeitrag
news:f8qdnYmC_I0kaKLenZ2dnUVZ_sidnZ2d@comcast.com. ..[color=blue]
> Try replacing the line ...
> DoCmd.RunCommand acCmdUndo
>
> With
> Cancel = True
>
> --
>
> Danny J. Lesandrini
> dlesandrini@hotmail.com
> http://amazecreations.com/datafast/
>
>
>
> "Alan Oats" <chrazer@gmail.com> wrote in message
> news:433fef06_3@news.bluewin.ch...[color=green]
>>I want to use this code from http://www.mvps.org/access/forms/frm0027.htm
>>
>>
>> Private Sub Form_BeforeUpdate(Cancel As Integer)
>> Dim strMsg As String
>> strMsg = "Data has changed."
>> strMsg = strMsg & "@Do you wish to save the changes?"
>> strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
>> If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
>> 'do nothing
>> Else
>> DoCmd.RunCommand acCmdUndo
>>
>> 'For Access 95, use DoMenuItem instead
>> 'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
>> End If
>> End Sub
>>
>>
>> For me in Access 2003 "German" this does not function.
>>
>> the code breaks and reports that this function is not available at the
>> moment.
>>
>> Thanks Alan
>>[/color]
>
>[/color]


Danny J. Lesandrini
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Ask before saving record


Well, I didn't want to suggest this, but there's always SendKeys "{ESC}"

--

Danny J. Lesandrini
dlesandrini@hotmail.com
http://amazecreations.com/datafast/



"Alan Oats" <chrazer@gmail.com> wrote in message news:43400db9$1_1@news.bluewin.ch...[color=blue]
> That works partially. It stops the record update. It does not however return the changed records to its original
> format. The only way is by using the escape key. It is an improvement but adds a little complexity to the user
> interface.
>
> Thankyou for the help I am at least one step further with this tip.
>
>
>
> Alan
>
>
> "Danny J. Lesandrini" <dlesandrini@hotmail.com> schrieb im Newsbeitrag
> news:f8qdnYmC_I0kaKLenZ2dnUVZ_sidnZ2d@comcast.com. ..[color=green]
>> Try replacing the line ...
>> DoCmd.RunCommand acCmdUndo
>>
>> With
>> Cancel = True
>>
>> --
>>
>> Danny J. Lesandrini
>> dlesandrini@hotmail.com
>> http://amazecreations.com/datafast/
>>
>>
>>
>> "Alan Oats" <chrazer@gmail.com> wrote in message news:433fef06_3@news.bluewin.ch...[color=darkred]
>>>I want to use this code from http://www.mvps.org/access/forms/frm0027.htm
>>>
>>>
>>> Private Sub Form_BeforeUpdate(Cancel As Integer)
>>> Dim strMsg As String
>>> strMsg = "Data has changed."
>>> strMsg = strMsg & "@Do you wish to save the changes?"
>>> strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
>>> If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
>>> 'do nothing
>>> Else
>>> DoCmd.RunCommand acCmdUndo
>>>
>>> 'For Access 95, use DoMenuItem instead
>>> 'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
>>> End If
>>> End Sub
>>>
>>>
>>> For me in Access 2003 "German" this does not function.
>>>
>>> the code breaks and reports that this function is not available at the moment.
>>>
>>> Thanks Alan
>>>[/color]
>>
>>[/color]
>
>[/color]


Alan Oats
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Ask before saving record


Danny J. Lesandrini wrote:[color=blue]
> Well, I didn't want to suggest this, but there's always SendKeys "{ESC}"
>[/color]

I am not at work now but I will give it a try tomorrow.

Thank you for the help

Alan
David W. Fenton
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Ask before saving record


"Alan Oats" <chrazer@gmail.com> wrote in
news:43400db9$1_1@news.bluewin.ch:
[color=blue]
> That works partially. It stops the record update. It does not
> however return the changed records to its original format. The
> only way is by using the escape key. It is an improvement but
> adds a little complexity to the user interface.[/color]

You can fix that with Me.Undo added before or after the Cancel =
True.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
David W. Fenton
Guest
 
Posts: n/a
#7: Nov 13 '05

re: Ask before saving record


Alan Oats <chrazer@gmail.com> wrote in
news:434049a0$0$1152$5402220f@news.sunrise.ch:
[color=blue]
> Danny J. Lesandrini wrote:[color=green]
>> Well, I didn't want to suggest this, but there's always SendKeys
>> "{ESC}"[/color]
>
> I am not at work now but I will give it a try tomorrow.[/color]

Dunno if you saw my post, but Me.Undo is the same as hitting the
ESCAPE key once.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Alan Oats
Guest
 
Posts: n/a
#8: Nov 13 '05

re: Ask before saving record


Yes that works beautifully. Thanks for the tip. I had to be back in the
office before I could try it and it works perfectly.

Alan

[color=blue]
> Dunno if you saw my post, but Me.Undo is the same as hitting the
> ESCAPE key once.
>
> --
> David W. Fenton http://www.bway.net/~dfenton
> dfenton at bway dot net http://www.bway.net/~dfassoc[/color]


Closed Thread