Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subforms inside a tab control

Status
Not open for further replies.

filmgall

Programmer
Oct 19, 2009
7
0
0
US
I have a form with a tab control and each tab page contains a subform. My question is how can I run an initialization code for each subform when the user clicks its tab. The code bas to refer to an input value from the main form. I tried the load event procedure for the subform but it would not work since the subform is loaded when the main form is loaded. I tried something like page.click() but it doesn't work either. Any idea?
 
The page click event is not what you think. You need to use the onChange event of the tabcontrol and the value property of the tabcontrol. If I change from page 1 to page two, the value of the tab control changes from 0 to 1.

So the value of the tabcontrol is equal to the index of the page. (zero based)
 
I had this trouble some time ago so I placed all my coding on a 'Next' button to go from tab to tab, as I did not get any satisfactory way of clicking the tab itself.

Hampshire UK.

A fool and his money are soon parted - so you might as well send it to me!
 

Code:
Private Sub YourTabbedControl_Change()
  Select Case YourTabbedControl 
    Case 0  ‘First Page
      ‘Code for Page 1
    Case 1  ‘Second page
      ‘Code for Page 2
   Case 2   ‘Third page
     ‘Code for Page 3
  End Select
End Sub

.


The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I got the idea now. Thanks both MajP and misslinq!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top