知識社群Login
[Access VBA] tab Control
by 艾鍗學院, 2012-12-29 18:47, Views(1205)

As gemma has suggested, the OnClick event for a tabbed control is nearly useless! You have to use the OnChange event. Here's a short tutorial:

The first thing to understand is that tabbed pages are indexed starting with zero, i.e. the first page has a value of 0, second page has a value of 1, 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!

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.

Code:
Private Sub YourTabbedControl_Change()
If Me.YourTabbedControl.Value = 0 Then 'First Page
  'Do code for Page 1
ElseIf Me.YourTabbedControl.Value = 1 Then 'Second page
  'Do code for Page 2
ElseIf Me.YourTabbedControl.Value = 2 Then 'Third page
  'Do code for Page 3
End If
End Sub