Change tab event

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

Guest

I have an unbound form and would like to load control values when a tab is
opened and save those values when user moves to another tab.
Here is my code so far:

Private Sub TabCtl0_Change()
Select Case Me.TabCtl0.Pages(Me.TabCtl0.Value).Name
Case "page1"
Dim frm As New Form_frmSubAdjv
Set frm = Me.frmSubAdjv.Form
frm.LoadForm
Case "page2"
Dim frm1 As New Form_frmSubClin
Set frm1 = Me.frmSubClin.Form
frm1.LoadForm
End Select
End Sub

Each tab has a subform and I am trying to tell it to load that subform.
I have a public function LoadForm in the subform and that is successful for
the first page. If I try to tab to the 2nd page, I get the error "item cannot
be found in the collection corresponding to the requested name or ordinal."
Any help?
Thanks very much.
 
when you run:
Dim frm As New Form_frmSubAdjv
Set frm = Me.frmSubAdjv.Form
frm.LoadForm

you creating a new form instance, instead of referening to subform

try to use following syntax:
Dim frm As Form
Set frm = Me.frmSubAdjv.Form
frm.LoadForm
 
Back
Top