Disable cmd button - focus problem

  • Thread starter Thread starter Nick Del Vecchio
  • Start date Start date
N

Nick Del Vecchio

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?
 
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.
 
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
 
Back
Top