Using tabs to make subforms visible

R

ram

Hi to All,

I am looking for help with the following question.

I have form with a 3 page tab control. Each page of the control has a
subform with summary detail. I also have the detail hidden on 3 additional
subforms.

How can I have the corrosponding detail form made visible when the person
click on the summary tab?

This is an example ofthe code I ws trying to use

Private Sub Page12_Click()
Forms!Start!CSOqryMonthlyReimb.Visible = True
Forms!Start!REPqryMonthlyReimb.Visible = False
Forms!Start!OtherqryMonthlyReimb.Visible = False

Thanks in advance for any help
 
T

tina

don't use the individual Page events, use the TabCtl Change event. the value
of the tab control equals the value of the PageIndex property of the
currently selected page. so if the first page is selected, the value of the
TabCtl = 0; if the second page is selected then TabCtl = 1, and so on. next,
a subform is a control on a main form, it's not a separate form while being
using in the main form. yet your code is written as if you have three
additional form objects (NOT subforms) open. i'll give you an example of
code where the detail "subforms" are in fact subforms on the main form, as

Private Sub TabCtl0_Change()

Me!DetailSubform1.Visible = (Me!TabCtl0 = 0)
Me!DetailSubform2.Visible = (Me!TabCtl0 = 1)
Me!DetailSubform3.Visible = (Me!TabCtl0 = 2)

End Sub

in the example above, replace DetailSubform1, etc, with the correct names of
the subform *controls* in the main form. also replace TabCtl0 in every
instance with the correct name of your tab control.

having said all that, i also have to say that six bound subforms is a lot
for one form - when it isn't necessary; the more bound subforms you put in a
mainform, the longer it takes to load. i'd recommend that you use only 2
subforms: one for the summary detail and one for the corresponding detail.
use the tab control's Change event to change the SourceObject of each
subform control to the appropriate form name that you want to display.
example:

Private Sub TabCtl0_Change()

Select Case Me!TabCtl0
Case 0 ' first tab page is selected
Me!SubformControl1.SourceObject = "Summary1"
Me!SubformControl2.SourceObject = "Detail1"
Case 1 ' second tab page is selected
Me!SubformControl1.SourceObject = "Summary2"
Me!SubformControl2.SourceObject = "Detail2"
Case 2 ' third tab page is selected
Me!SubformControl1.SourceObject = "Summary3"
Me!SubformControl2.SourceObject = "Detail3"

End Sub

if the subform tables are linked to the RecordSource in the main form, you
may need to change the LinkChildFields and LinkMasterFields properties as
well. if so, do that in the above code, in addition to changing the
SourceObject properties of the two subforms.

hth
 
R

ram

Tina thank you for your reply

When I use your code I receive the following error

Microsoft Access can't find the field 'tabctl1' referred to in your
expression.
I tried changing the tabctl to the page for each tab and still receive the
same message. Do you know what I have done wrong?

Thanks
 
R

ram

HI Tina, I got it working i had the wrong number for the control.

Thanks again for all your suggestion, I have a lot to learn.
 
T

tina

you're welcome, and good job in troubleshooting your error message - that's
an excellent learning process in itself. as for having a lot to learn, join
the crowd! all of us here in these ngs can always learn something new about
Access, even those folks with tons of expertise. there will always be people
ahead of us and behind us on the learning road, so just keep chugging along
at your own pace! :)
 

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