-----Original Message-----
Hi Maureen,
Instead of setting/unsetting the recordsources, I generally
bind/unbind the suborm by setting/unsetting the Sourceobject of the
subforms. Create an OnChange event for the tabcontrol itself that
sets the SourceObject property of correct subform based on the new
value of the tabcontrol. Remember that the value of the tab control
is actually the page index of the current tab page where 0 refers to
the first tab page.
When I design a complex for this way, my onChange event also clears
the SourceObject of the subform that is being hidden. Here's some
sample code - note that on each of the cases instead of using
absolute page numbers I get the page number by getting the pageindex
of a named page. I do this because the page index of a page changes
if you reorder the pages but I tend to leave the names alone once
I've set them. This just reduces maintenance and prevents weird
errors when you reorder the pages but forget to adjust the code.
To be honest, I'm not sure how to do this with macros (or whether
you'd want to because of no error handling). Here's how to do it
with VBA:
'Module level variable
Private mIntCurTabPage As Integer
Private Sub TabCtl8_Change()
'Clear the SourceObject of subform on tabpage we're leaving
Select Case mIntCurTabPage
Case Me.TabCtl8.Pages("pgFirstPageName").PageIndex
Me.sfrmFirst.SourceObject = vbNullString
Case Me.TabCtl8.Pages("pgSecondPageName").PageIndex
Me.sfrmSecond.SourceObject = vbNullString
Case Me.TabCtl8.Pages("pgThirdPageName").PageIndex
Me.sfrmThird.SourceObject = vbNullString
Case Me.TabCtl8.Pages("pgFourthPageName").PageIndex
Me.sfrmFourth.SourceObject = vbNullString
End Select
Select Case Me.TabCtl8
Case Me.TabCtl8.Pages("pgFirstPageName").PageIndex
Me.sfrmFirst.SourceObject = "sfrmOrders"
Case Me.TabCtl8.Pages("pgSecondPageName").PageIndex
Me.sfrmSecond.SourceObject = "sfrmOrders2"
Case Me.TabCtl8.Pages("pgThirdPageName").PageIndex
Me.sfrmThird.SourceObject = "sfrmOrders3"
Case Me.TabCtl8.Pages("pgFourthPageName").PageIndex
Me.sfrmFourth.SourceObject = "sfrmOrders4"
End Select
mIntCurTabPage = Me.TabCtl8
End Sub
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
I have an access 2002 DB - split frontend/backend -
devleoped on WinXP which needs to run on a WinNT server.
One of my forms has 5 tabbed controls (pages) each of
which contains a separate subform, all linked to the
mainform. The record source for each subform is a query -
all calc's have been removed from the queries.
Problem is - the form is too slow. I'm trying to follow
a suggestion to remove the recordsourse of each subform
and then only supply that info once that tab/page is
selected (clicked on).
I need to use macros since I do not know visual basic -
or I need to have some kind soul provide me with the
visbasic so I can modify the existing coding.
Can anyone offer some detailed assistance, please??
Thank you!
.