A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Cancel button question



 
 
Thread Tools Display Modes
  #1  
Old May 29th, 2006, 11:14 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Cancel button question

I have a number of forms with a cancel button. If the user clicks on the
cancel button they get a standard Access message box. I want the use to see
a box that says "You haven't changed anything? There is nothing to cancel.
Did you mean to Close the form? If so click Yes"
And the message box would have yes/ no buttons. The creation of the message
box is OK I can do that but how do intercept the Access message box and what
code do I need to use to check whether anything has changed?
Thanks
Tony


  #2  
Old May 29th, 2006, 11:58 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Cancel button question

Check whether the form's Dirty property is set to True. If it isn't, they
haven't made any changes.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
I have a number of forms with a cancel button. If the user clicks on the
cancel button they get a standard Access message box. I want the use to

see
a box that says "You haven't changed anything? There is nothing to cancel.
Did you mean to Close the form? If so click Yes"
And the message box would have yes/ no buttons. The creation of the

message
box is OK I can do that but how do intercept the Access message box and

what
code do I need to use to check whether anything has changed?
Thanks
Tony




  #3  
Old May 29th, 2006, 12:08 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Cancel button question

Thanks Douglas. is that as simple as
"If Me.Dirty = True Then Magbee"
Will this intercept the Access message?
Thanks
Tony

"Douglas J Steele" wrote in message
...
Check whether the form's Dirty property is set to True. If it isn't, they
haven't made any changes.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
I have a number of forms with a cancel button. If the user clicks on the
cancel button they get a standard Access message box. I want the use to

see
a box that says "You haven't changed anything? There is nothing to
cancel.
Did you mean to Close the form? If so click Yes"
And the message box would have yes/ no buttons. The creation of the

message
box is OK I can do that but how do intercept the Access message box and

what
code do I need to use to check whether anything has changed?
Thanks
Tony






  #4  
Old May 29th, 2006, 02:35 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Cancel button question

What's your code for cancelling look like?

Did you try to see whether it works?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
Thanks Douglas. is that as simple as
"If Me.Dirty = True Then Magbee"
Will this intercept the Access message?
Thanks
Tony

"Douglas J Steele" wrote in message
...
Check whether the form's Dirty property is set to True. If it isn't,

they
haven't made any changes.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
I have a number of forms with a cancel button. If the user clicks on

the
cancel button they get a standard Access message box. I want the use to

see
a box that says "You haven't changed anything? There is nothing to
cancel.
Did you mean to Close the form? If so click Yes"
And the message box would have yes/ no buttons. The creation of the

message
box is OK I can do that but how do intercept the Access message box and

what
code do I need to use to check whether anything has changed?
Thanks
Tony








  #5  
Old May 30th, 2006, 10:56 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Cancel button question

Douglas I've used this code and it seems to work OK

Private Sub cmdcancel_Click()
Dim strMsg As String

On Error GoTo Err_cmdcancel_Click
strMsg = "You haven't changed any data. Do want to close the form"

If Me.Dirty = False Then
If MsgBox(strMsg, vbQuestion + vbYesNo, "Close form?") = vbYes Then
DoCmd.Close
End If
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
Exit_cmdcancel_Click:
Exit Sub

Err_cmdcancel_Click:
MsgBox Err.Description
Resume Exit_cmdcancel_Click

End Sub

Can you see anything I might change?
Thanks
Tony
"Douglas J Steele" wrote in message
...
What's your code for cancelling look like?

Did you try to see whether it works?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
Thanks Douglas. is that as simple as
"If Me.Dirty = True Then Magbee"
Will this intercept the Access message?
Thanks
Tony

"Douglas J Steele" wrote in message
...
Check whether the form's Dirty property is set to True. If it isn't,

they
haven't made any changes.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
I have a number of forms with a cancel button. If the user clicks on

the
cancel button they get a standard Access message box. I want the use
to
see
a box that says "You haven't changed anything? There is nothing to
cancel.
Did you mean to Close the form? If so click Yes"
And the message box would have yes/ no buttons. The creation of the
message
box is OK I can do that but how do intercept the Access message box
and
what
code do I need to use to check whether anything has changed?
Thanks
Tony










  #6  
Old May 30th, 2006, 01:25 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Cancel button question

I'm not a big fan of using MenuItems in code.

You could try replacing

DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

with

Me.Undo

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
Douglas I've used this code and it seems to work OK

Private Sub cmdcancel_Click()
Dim strMsg As String

On Error GoTo Err_cmdcancel_Click
strMsg = "You haven't changed any data. Do want to close the form"

If Me.Dirty = False Then
If MsgBox(strMsg, vbQuestion + vbYesNo, "Close form?") = vbYes Then
DoCmd.Close
End If
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
Exit_cmdcancel_Click:
Exit Sub

Err_cmdcancel_Click:
MsgBox Err.Description
Resume Exit_cmdcancel_Click

End Sub

Can you see anything I might change?
Thanks
Tony
"Douglas J Steele" wrote in message
...
What's your code for cancelling look like?

Did you try to see whether it works?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
Thanks Douglas. is that as simple as
"If Me.Dirty = True Then Magbee"
Will this intercept the Access message?
Thanks
Tony

"Douglas J Steele" wrote in message
...
Check whether the form's Dirty property is set to True. If it isn't,

they
haven't made any changes.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
I have a number of forms with a cancel button. If the user clicks on

the
cancel button they get a standard Access message box. I want the use
to
see
a box that says "You haven't changed anything? There is nothing to
cancel.
Did you mean to Close the form? If so click Yes"
And the message box would have yes/ no buttons. The creation of the
message
box is OK I can do that but how do intercept the Access message box
and
what
code do I need to use to check whether anything has changed?
Thanks
Tony












  #7  
Old May 31st, 2006, 01:47 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Cancel button question

Ok Douglas I live and learn
Tony
"Douglas J Steele" wrote in message
...
I'm not a big fan of using MenuItems in code.

You could try replacing

DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

with

Me.Undo

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
Douglas I've used this code and it seems to work OK

Private Sub cmdcancel_Click()
Dim strMsg As String

On Error GoTo Err_cmdcancel_Click
strMsg = "You haven't changed any data. Do want to close the form"

If Me.Dirty = False Then
If MsgBox(strMsg, vbQuestion + vbYesNo, "Close form?") = vbYes Then
DoCmd.Close
End If
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
Exit_cmdcancel_Click:
Exit Sub

Err_cmdcancel_Click:
MsgBox Err.Description
Resume Exit_cmdcancel_Click

End Sub

Can you see anything I might change?
Thanks
Tony
"Douglas J Steele" wrote in message
...
What's your code for cancelling look like?

Did you try to see whether it works?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
Thanks Douglas. is that as simple as
"If Me.Dirty = True Then Magbee"
Will this intercept the Access message?
Thanks
Tony

"Douglas J Steele" wrote in
message
...
Check whether the form's Dirty property is set to True. If it isn't,
they
haven't made any changes.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Tony Williams" wrote in message
...
I have a number of forms with a cancel button. If the user clicks
on
the
cancel button they get a standard Access message box. I want the
use
to
see
a box that says "You haven't changed anything? There is nothing to
cancel.
Did you mean to Close the form? If so click Yes"
And the message box would have yes/ no buttons. The creation of
the
message
box is OK I can do that but how do intercept the Access message box
and
what
code do I need to use to check whether anything has changed?
Thanks
Tony














 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
there should be a cancel button when exiting outlook cilag71 General Discussion 7 September 15th, 2005 03:27 PM
2 part question - macro / command button John General Discussion 3 April 16th, 2005 09:00 PM
cancel button for form robin Using Forms 3 March 16th, 2005 10:47 PM
Creating a Cancel and Undo Button Nick in Tokyo Using Forms 3 August 19th, 2004 11:55 AM
follow upd question command button singkit Worksheet Functions 3 June 8th, 2004 08:49 PM


All times are GMT +1. The time now is 03:03 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.