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 not working



 
 
Thread Tools Display Modes
  #11  
Old February 23rd, 2010, 05:04 PM posted to microsoft.public.access.forms
Jesse via AccessMonster.com
external usenet poster
 
Posts: 29
Default Cancel Button not working

Thank you for your input. To get it to work on the report open I used this.

Dim Response As Long

Response = MsgBox("Approximate wait time is 5 minutes." _
& Chr(13) & Chr(10) & _
"Push OK to continue,Cancel to Quit", vbOKCancel)
If Response = vbCancel Then
DoCmd.CancelEvent
End If

The docmd.canceEvent works good except it maximizing the form. I have the
code on the report to maximize on open and restore on close to restore the
form to the size i have it. But if you press the cancel button it still
maximizes the form and does not complete the restore docmd. Not a huge deal
but still would be nice to have it work clean. If you have any insite on this
issue I would be happy to listen and learn. Thanks

BruceM wrote:
I meant to mention that Douglas posted code for the Click event of a command
button, not the report's Open event. You were trying to open a report in its
own Open event.

I have fixed my problem with a different path. I placed the code on the
command click instead of having it on the report open. It works the way its

[quoted text clipped - 5 lines]
All
you're doing is presenting a message!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201002/1

  #12  
Old February 23rd, 2010, 05:45 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Cancel Button not working

Maximizing which form? Are you referring to code in the command button that
opens the report? You could try Cancel = True rather than DoCmd.CancelEvent,
but I doubt it will make a difference?

Jesse wrote:
Thank you for your input. To get it to work on the report open I used this.

Dim Response As Long

Response = MsgBox("Approximate wait time is 5 minutes." _
& Chr(13) & Chr(10) & _
"Push OK to continue,Cancel to Quit", vbOKCancel)
If Response = vbCancel Then
DoCmd.CancelEvent
End If

The docmd.canceEvent works good except it maximizing the form. I have the
code on the report to maximize on open and restore on close to restore the
form to the size i have it. But if you press the cancel button it still
maximizes the form and does not complete the restore docmd. Not a huge deal
but still would be nice to have it work clean. If you have any insite on this
issue I would be happy to listen and learn. Thanks

I meant to mention that Douglas posted code for the Click event of a command
button, not the report's Open event. You were trying to open a report in its

[quoted text clipped - 5 lines]
All
you're doing is presenting a message!


--
Message posted via http://www.accessmonster.com

  #13  
Old February 23rd, 2010, 06:04 PM posted to microsoft.public.access.forms
Jesse via AccessMonster.com
external usenet poster
 
Posts: 29
Default Cancel Button not working

I have a form that is built as a switchboard. When I press a command it
follows the handle number then opens a report. On the report properties I
have event procedures on the "On Open" and "On Close". the on open I tell it
to maximize and on the on close I tell it to restore. I have the form not
maximized in the access database but when you maximize a report it maximizes
the form unless you tell it to restore on close. then it puts the form window
back to the size you have previously set. So when I use the code below and
the user presses ok the report runs and on close the form is restored. But if
the user presses the cancel button the form stays maximized because for some
reason the restore command doesn’t occur.

BruceM wrote:
Maximizing which form? Are you referring to code in the command button that
opens the report? You could try Cancel = True rather than DoCmd.CancelEvent,
but I doubt it will make a difference?

Thank you for your input. To get it to work on the report open I used this.

[quoted text clipped - 19 lines]
All
you're doing is presenting a message!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201002/1

  #14  
Old February 23rd, 2010, 07:23 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Cancel Button not working

Try restoring (Me.Restore) in the Activate event of the form. Restoring in
the Close event of the report applies Restore to that report, not to any
other object. I'm not sure why it works as you would like in one instance
but not the other, but I do think the code needs to be in the form's Activate
event.

Jesse wrote:
I have a form that is built as a switchboard. When I press a command it
follows the handle number then opens a report. On the report properties I
have event procedures on the "On Open" and "On Close". the on open I tell it
to maximize and on the on close I tell it to restore. I have the form not
maximized in the access database but when you maximize a report it maximizes
the form unless you tell it to restore on close. then it puts the form window
back to the size you have previously set. So when I use the code below and
the user presses ok the report runs and on close the form is restored. But if
the user presses the cancel button the form stays maximized because for some
reason the restore command doesn’t occur.

Maximizing which form? Are you referring to code in the command button that
opens the report? You could try Cancel = True rather than DoCmd.CancelEvent,

[quoted text clipped - 5 lines]
All
you're doing is presenting a message!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201002/1

  #15  
Old February 23rd, 2010, 08:15 PM posted to microsoft.public.access.forms
Jesse via AccessMonster.com
external usenet poster
 
Posts: 29
Default Cancel Button not working

I placed the me.restore in the activate event and it gave me an error of
"Application-defined or abject-defined error". After I typed the . it didnt
show restore in the list of objects that i could use. So it doesnt work in
the activate event. Im not sure why it works in one instance but not the
other either. Access can be strange sometimes.

BruceM wrote:
Try restoring (Me.Restore) in the Activate event of the form. Restoring in
the Close event of the report applies Restore to that report, not to any
other object. I'm not sure why it works as you would like in one instance
but not the other, but I do think the code needs to be in the form's Activate
event.

I have a form that is built as a switchboard. When I press a command it
follows the handle number then opens a report. On the report properties I

[quoted text clipped - 12 lines]
All
you're doing is presenting a message!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201002/1

  #16  
Old February 24th, 2010, 12:16 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Cancel Button not working

Oops. Try DoCmd.Restore. Sorry about that. I used the syntax for Requery
and Refresh, but Restore is applied differently.

Jesse wrote:
I placed the me.restore in the activate event and it gave me an error of
"Application-defined or abject-defined error". After I typed the . it didnt
show restore in the list of objects that i could use. So it doesnt work in
the activate event. Im not sure why it works in one instance but not the
other either. Access can be strange sometimes.

Try restoring (Me.Restore) in the Activate event of the form. Restoring in
the Close event of the report applies Restore to that report, not to any

[quoted text clipped - 7 lines]
All
you're doing is presenting a message!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201002/1

  #17  
Old February 24th, 2010, 03:19 PM posted to microsoft.public.access.forms
Jesse via AccessMonster.com
external usenet poster
 
Posts: 29
Default Cancel Button not working

That worked perfectly Bruce. Thank you for your help and for your time.

BruceM wrote:
Oops. Try DoCmd.Restore. Sorry about that. I used the syntax for Requery
and Refresh, but Restore is applied differently.

I placed the me.restore in the activate event and it gave me an error of
"Application-defined or abject-defined error". After I typed the . it didnt

[quoted text clipped - 7 lines]
All
you're doing is presenting a message!


--
Message posted via http://www.accessmonster.com

 




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


All times are GMT +1. The time now is 04:52 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.