run code on tab click

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!!!
 
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.
 
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.
 
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.
 
smk23 said:
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?

I don't understand what you want to do. When focus moves from a subform to the
parent or from one subform to another subform the record in the form being left
is automatically saved. You don't need to do anything.
 
Back
Top