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  

Disable cmd button - focus problem



 
 
Thread Tools Display Modes
  #1  
Old March 3rd, 2010, 02:42 PM posted to microsoft.public.access.forms
Nick Del Vecchio
external usenet poster
 
Posts: 19
Default Disable cmd button - focus problem

I have a cmd button (filter button) that enables another button (print
preview button).
I then disable this print preview button after it is clicked by first
setting the focus to another control and then disabling the button.
That works fine.

Private Sub cmdSpecialPreview_Click()
DoCmd.OpenReport "rptPrintPreview", acViewPreview, , strWhere
cmdFilterOff.SetFocus
cmdSpecialPreview.Enabled = False
End Sub

The problem is that if the user clicks the first button (which enables
the 2nd button) and then clicks somewhere else. This keeps the second
button enabled.

I tried to disable the 2nd button in the lost focus event, but I get a
message that I can not disable a button that has focus. I don't
understand why I would get this message since I assumed it is only
supposed to fire when the button loses focus.


How can I disable this 2nd button if the next button the user clicks
is not the 2nd button?
  #2  
Old March 3rd, 2010, 03:32 PM posted to microsoft.public.access.forms
RonaldoOneNil
external usenet poster
 
Posts: 345
Default Disable cmd button - focus problem

Either in the same code that enables the 2nd button, disable all other
buttons so that they can only press the 2nd button. In the 2nd button code
enable all the buttons again.

Or

In the click code of all the other buttons, diable the 2nd button.

"Nick Del Vecchio" wrote:

I have a cmd button (filter button) that enables another button (print
preview button).
I then disable this print preview button after it is clicked by first
setting the focus to another control and then disabling the button.
That works fine.

Private Sub cmdSpecialPreview_Click()
DoCmd.OpenReport "rptPrintPreview", acViewPreview, , strWhere
cmdFilterOff.SetFocus
cmdSpecialPreview.Enabled = False
End Sub

The problem is that if the user clicks the first button (which enables
the 2nd button) and then clicks somewhere else. This keeps the second
button enabled.

I tried to disable the 2nd button in the lost focus event, but I get a
message that I can not disable a button that has focus. I don't
understand why I would get this message since I assumed it is only
supposed to fire when the button loses focus.


How can I disable this 2nd button if the next button the user clicks
is not the 2nd button?
.

  #3  
Old March 3rd, 2010, 08:37 PM posted to microsoft.public.access.forms
Nick Del Vecchio
external usenet poster
 
Posts: 19
Default Disable cmd button - focus problem

I was afraid this might be the only solution - but I had to ask.
I went with the 2nd suggestion. Took a little work but it is working
fine now.
Thanks
 




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 03:49 AM.


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