Automatically changing tabs in main form when changing tabs in subform

dcnick

Registered User.
Local time
Today, 13:38
Joined
Feb 26, 2002
Messages
38
Hello.

I have a form (Frm1) with a subform (Subfrm1). Both Frm1 and Subfrm1 have tabs. When I select a tab in the subform, I would like to write VBA code to select a specific tab on the main form.

So, In Frm1, I have TabCtl10 with Page11 and Page12.
In Subfrm1, I have TabCtl20 with Page21 and Page22.

If I select Page21 in the subform, I would automatically like Page 11 in the main form to appear.

I have tried the following as an "on click" event when selecting Page21, and it doesn't work:

Forms("Frm1")!Controls(TabCtl10)!Pages(Page11).SetFocus

Thanks in advance.
 
Found the answer and went in a totally different direction and used tab control values.

I tried placing this code under "on click" for the individual tabs, but that did not work. Instead, I placed this code under "on change" for the entire tab sheet (TabCtl20).

Code:
If Me.TabCtl20.Value = 0 Then
  Forms!frmDataList_PLAY!Page11.SetFocus
End If

If Me.TabCtl20.Value = 1 Then
  Forms!frmDataList_PLAY!Page12.SetFocus
End If

Also could have used If...Then...Else, since I currently only have 2 tabs.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom