return Subform Name on Tab control

T

tighe

all,

a little background i was using Screen.ActiveForm![Firm_ID], in a function
to use as a query criteria, now all my [Firm_ID]s, are on tabbed subforms.
my quick fix was have a txt1= [subformname].Form![Firm_ID], but the subform
name could be one of 7, so i am tring to figure out how to capture the name
of the current subform based on the tab page the user is on or the current
records Firm_ID.

i looked around and have been playing with:
Dim ctl As control
s = Screen.ActiveForm.Name
For Each ctl In Forms(s).Controls
If ctl.ControlType = acSubform Then
If ctl.visible Then 'many are visible, so i tried, current,
enabled, others, everything errors or returns page0
MsgBox "The visible subform control is called "
Exit For
End If
End If
Next

i also found what tab page i am
on:Forms![Acct_Full_Processing]![TabCtl71].Value
but i am not sure how further this idea to return the form the user is on or
the Firm_id associated with the current record of the particular sub form.

all forms are continuous
running Xp AC2007

TIA
 
M

Marshall Barton

tighe said:
a little background i was using Screen.ActiveForm![Firm_ID], in a function
to use as a query criteria, now all my [Firm_ID]s, are on tabbed subforms.
my quick fix was have a txt1= [subformname].Form![Firm_ID], but the subform
name could be one of 7, so i am tring to figure out how to capture the name
of the current subform based on the tab page the user is on or the current
records Firm_ID.

i looked around and have been playing with:
Dim ctl As control
s = Screen.ActiveForm.Name
For Each ctl In Forms(s).Controls
If ctl.ControlType = acSubform Then
If ctl.visible Then 'many are visible, so i tried, current,
enabled, others, everything errors or returns page0
MsgBox "The visible subform control is called "
Exit For
End If
End If
Next

i also found what tab page i am
on:Forms![Acct_Full_Processing]![TabCtl71].Value
but i am not sure how further this idea to return the form the user is on or
the Firm_id associated with the current record of the particular sub form.

all forms are continuous
running Xp AC2007

Each tab page has a Controls collection so you could search
in that for the (one) subform control on the page.

With Forms(s)
For Each ctl In .TabCtl71.Pages(.TabCtl71).Controls
If ctl.ControlType = acSubform Then
txt1= ctl.Form.Firm_ID
 
T

tighe

that works perfectly!

thanks Marsh

Marshall Barton said:
tighe said:
a little background i was using Screen.ActiveForm![Firm_ID], in a function
to use as a query criteria, now all my [Firm_ID]s, are on tabbed subforms.
my quick fix was have a txt1= [subformname].Form![Firm_ID], but the subform
name could be one of 7, so i am tring to figure out how to capture the name
of the current subform based on the tab page the user is on or the current
records Firm_ID.

i looked around and have been playing with:
Dim ctl As control
s = Screen.ActiveForm.Name
For Each ctl In Forms(s).Controls
If ctl.ControlType = acSubform Then
If ctl.visible Then 'many are visible, so i tried, current,
enabled, others, everything errors or returns page0
MsgBox "The visible subform control is called "
Exit For
End If
End If
Next

i also found what tab page i am
on:Forms![Acct_Full_Processing]![TabCtl71].Value
but i am not sure how further this idea to return the form the user is on or
the Firm_id associated with the current record of the particular sub form.

all forms are continuous
running Xp AC2007

Each tab page has a Controls collection so you could search
in that for the (one) subform control on the page.

With Forms(s)
For Each ctl In .TabCtl71.Pages(.TabCtl71).Controls
If ctl.ControlType = acSubform Then
txt1= ctl.Form.Firm_ID
 

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