run code on tab click

S

smk23

I would like to load the controls on a tab page when the tab is clicked or
entered. I put code on the click event for that tab with no results.

Here is the code on the click event:

Private Sub ClinStage_Click()

Dim fBOSC As Form
Set fBOSC = Me.frmBrOncSubClin.Form
fBOSC.pAilmentID = mlngAilmentID
fBOSC.LoadForm

End Sub

LoadForm is a public sub on the frmBrOncSubClin form.

This same code works fine when I use it on entering the main form, so I know
that the LoadForm code is fine. But I prefer to load this subform only when
that tab is being used. What am I missing?
Thanks!!!
 
R

Rick Brandt

smk23 said:
I would like to load the controls on a tab page when the tab is
clicked or entered. I put code on the click event for that tab with
no results. [snip]

The Click event of a TabPage does not fire when you click on the "tab". Use
the Change event of the TabControl itself and test the value property to see
which page was selected.
 
S

smk23

Thanks again, Rick.
That worked. What should I use if I want to save the data as I move to the
next tab? (I have the save code, just looking for the event to fire it).
Sam

Rick Brandt said:
smk23 said:
I would like to load the controls on a tab page when the tab is
clicked or entered. I put code on the click event for that tab with
no results. [snip]

The Click event of a TabPage does not fire when you click on the "tab". Use
the Change event of the TabControl itself and test the value property to see
which page was selected.
 
S

smk23

I tried putting the save code on the same tab change event. How do I
initialize this? I save the name of the tab subform that I'm moving off of.

Me.Mainform.Subform.form.SaveData

This should work except when I move to the first tab, there is no previous
tab and I get an error that the previous Me.MainForm.Subform is not set. How
do I get around this?

sam
smk23 said:
Thanks again, Rick.
That worked. What should I use if I want to save the data as I move to the
next tab? (I have the save code, just looking for the event to fire it).
Sam

Rick Brandt said:
smk23 said:
I would like to load the controls on a tab page when the tab is
clicked or entered. I put code on the click event for that tab with
no results. [snip]

The Click event of a TabPage does not fire when you click on the "tab". Use
the Change event of the TabControl itself and test the value property to see
which page was selected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top