Change tab event

S

smk23

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.
 
A

Alex Dybenko

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
 

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