Set Focus on Pages of a Tab Control (1 Viewer)

RJW

Registered User.
Local time
Today, 03:48
Joined
Sep 21, 2006
Messages
44
I have a form (called: Current Month) with a 7 page Tab Control.
Each Page has a command button, which opens another form (a different form for each page)

I can set the focus to the command button on first Page when the Current Month form loads.

When I click on Page 2 of the Tab Control, I'd like the command button on Page 2 to have the focus.

And the same of I click on Page 3, or Page 5 ... or any Page I click on. When that Page is active, I'd like the button on that Page to have the focus.

Can this be done?

Thanks.
RJ Wellstead
 

missinglinq

AWF VIP
Local time
Today, 03:48
Joined
Jun 20, 2003
Messages
6,423
Here’s a short tutorial I post when this type of question arises:

The first thing to understand is that Tabbed Page Index is Zero-based, i.e. the first page has a value of 0, the second page has a value of 1, the third page has a value of 2, etc.

Secondly, you need to understand that the OnClick event of a Tabbed Page only fires when you click on the page itself, not the tab at the top of the page! (Rumor has it that this may change with later versions...not sure)

Lastly, you need to understand that the Tabbed Control change event fires anytime the Tabbed Pages change. But to base something on the change event, you have to identify the particular page that has focus. So, for your particular problem:

Code:
Private Sub YourTabbedControlName_Change()
  Select Case YourTabbedControlName 
    Case 0  'First Page 
      FirstPageButton.SetFocus
    Case 1  'Second page 
      SecondPageButton.SetFocus
    Case 2   'Third page
      ThirdPageButton.SetFocus
  End Select
End Sub
Replacing YourTabbedControlName with the actual name of your Tabbed Control, and FirstPageButton, SecondPageButton and ThirdPageButton, etc. with their actual names.

Linq ;0)>
 

RJW

Registered User.
Local time
Today, 03:48
Joined
Sep 21, 2006
Messages
44
Perfect !!

Thanks.

RJ Wellstead
 

Users who are viewing this thread

Top Bottom