error handling for setFocus

  • Thread starter Thread starter anonymous
  • Start date Start date
A

anonymous

I have tabs on my form where the focus is set to the first
tab.
I would like to have a switch(option buttons) to
enable/disable the tabs in order to reserve a number for later
use.

My Problem:
if I set the tabs enabled property to No, I receive the
following error:

Run-time error '2110':
Microsoft Access can't move the focus to the control Page1.
* The control may be a type that can't receive the focus,
such as a label.
* The control's Visible property may be set to No.
* The control's Enabled property may be set to No.

I realize the last line applies to my setting.

My Question:
Is there an error-handling code that I could use to bypass
the error, and just resume?

Here is the code that I used to set the focus on the first tab:
Private Sub Form_Current()
Me.TabCtl0.Pages("Page1").SetFocus
End Sub

any help will be a great help, thank you.
 
You can't disable a control while it has the focus. You have to move the
focus to some other control, first. Error handling will not help you (IMO).
It will hide the message, sure. But it will not let you disable a control
that has the focus!

HTH,
TC
 
Back
Top