Referring to a Tab Control

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

Guest

When the user changes tabs in a form I want the On Change Event to make
particular controls on the main form visible.

I tried:

Private Sub TabMainTab_Change()
Forms!frmStartUp!txtManual.Visible = Me.ActiveControl = "tabCurrentManual"
End Sub

Nope. I then tried a flurry of alternatives:

= Me.Page = "tabCurrentManual"
= Me.Page = 1
= Me.Pages.Index = 1
= Me.TabMainTab.Pages(1)

and a whole bunch of nonsense related to Screen and ActiveControl.

I'm pretty comfortable with "Forms!frmStartUp!txtManual.Visible =" because I
know it works. Where I am lost is in referring to the actual tab control.
If the Tab Index is 1 and the tab name is "tabCurrentManual" and the related
subform is "frmCurrentManual" I want particular fields to be visible. If,
however, the Tab Index is 2 and the tab name is "tabCurrentHolder" and the
related subform is "frmCurrentHolder" I want different fields to be visible
instead. With this many possible criteria to choose from, how can I possibly
go wrong?

It's like I'm playing battleship, and I'm hitting all around the right
syntax without actually scoring.
 
The value of the tabcontrol is the index of the current page. So, you want
to test it this way:

Forms!frmStartUp!txtManual.Visible = me.tabManTab=1

Or, using the name of the tab page (which I would prefer since the pageindex
might change if you make design changes)

Forms!frmStartUp!txtManual.Visible =
me.tabManTab=me.tabmantab("tabCurrentManual").PageIndex
 
Sandra,

#1 - You are so cool it hurts!
#2 - It refused "Forms!frmStartUp!txtManual.Visible = >
me.tabManTab=me.tabmantab("tabCurrentManual").PageIndex"
(When I roll over the line, it recognizes "me.tabManTab=1", but it still
claims a type mismatch when I activate the event. Whatever! I will just
stick with the first option and remember not to mess with the page order...
What could possibly go wrong?)
#3 - I really was close, wasn't I? (aaargh!)
#4 - How do you guys know this stuff? Is it really a matter of trial and
error or is there a resource?

Thnx so much for all your help. I hope to someday offer assistance, not
just take it.

Dale

Sandra Daigle said:
The value of the tabcontrol is the index of the current page. So, you want
to test it this way:

Forms!frmStartUp!txtManual.Visible = me.tabManTab=1

Or, using the name of the tab page (which I would prefer since the pageindex
might change if you make design changes)

Forms!frmStartUp!txtManual.Visible =
me.tabManTab=me.tabmantab("tabCurrentManual").PageIndex


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

When the user changes tabs in a form I want the On Change Event to
make particular controls on the main form visible.

I tried:

Private Sub TabMainTab_Change()
Forms!frmStartUp!txtManual.Visible = Me.ActiveControl =
"tabCurrentManual" End Sub

Nope. I then tried a flurry of alternatives:

= Me.Page = "tabCurrentManual"
= Me.Page = 1
= Me.Pages.Index = 1
= Me.TabMainTab.Pages(1)

and a whole bunch of nonsense related to Screen and ActiveControl.

I'm pretty comfortable with "Forms!frmStartUp!txtManual.Visible ="
because I know it works. Where I am lost is in referring to the
actual tab control. If the Tab Index is 1 and the tab name is
"tabCurrentManual" and the related subform is "frmCurrentManual" I
want particular fields to be visible. If, however, the Tab Index is
2 and the tab name is "tabCurrentHolder" and the related subform is
"frmCurrentHolder" I want different fields to be visible instead.
With this many possible criteria to choose from, how can I possibly
go wrong?

It's like I'm playing battleship, and I'm hitting all around the right
syntax without actually scoring.
 
#1 :-)

#2 I'm seeing some extra characters in your code. I'll write it with line
continuations to eliminate the chance that your newsreader is throwing in
extra punctuation that may be confusing the issue:

Forms!frmStartUp!txtManual.Visible = _
me.tabManTab=me.tabmantab("tabCurrentManual").PageIndex

#3 and #4 - yes you were quite close. The tab control value is documented in
the help somewhere but I think everyone learns it the hard way! This is one
of the best resources I ever found. I used quite a few books too.

Good luck!
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Sandra,

#1 - You are so cool it hurts!
#2 - It refused "Forms!frmStartUp!txtManual.Visible = >
me.tabManTab=me.tabmantab("tabCurrentManual").PageIndex"
(When I roll over the line, it recognizes "me.tabManTab=1", but it
still claims a type mismatch when I activate the event. Whatever! I
will just stick with the first option and remember not to mess with
the page order... What could possibly go wrong?)
#3 - I really was close, wasn't I? (aaargh!)
#4 - How do you guys know this stuff? Is it really a matter of trial
and error or is there a resource?

Thnx so much for all your help. I hope to someday offer assistance,
not just take it.

Dale

Sandra Daigle said:
The value of the tabcontrol is the index of the current page. So,
you want to test it this way:

Forms!frmStartUp!txtManual.Visible = me.tabManTab=1

Or, using the name of the tab page (which I would prefer since the
pageindex might change if you make design changes)

Forms!frmStartUp!txtManual.Visible =
me.tabManTab=me.tabmantab("tabCurrentManual").PageIndex


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

When the user changes tabs in a form I want the On Change Event to
make particular controls on the main form visible.

I tried:

Private Sub TabMainTab_Change()
Forms!frmStartUp!txtManual.Visible = Me.ActiveControl =
"tabCurrentManual" End Sub

Nope. I then tried a flurry of alternatives:

= Me.Page = "tabCurrentManual"
= Me.Page = 1
= Me.Pages.Index = 1
= Me.TabMainTab.Pages(1)

and a whole bunch of nonsense related to Screen and ActiveControl.

I'm pretty comfortable with "Forms!frmStartUp!txtManual.Visible ="
because I know it works. Where I am lost is in referring to the
actual tab control. If the Tab Index is 1 and the tab name is
"tabCurrentManual" and the related subform is "frmCurrentManual" I
want particular fields to be visible. If, however, the Tab Index is
2 and the tab name is "tabCurrentHolder" and the related subform is
"frmCurrentHolder" I want different fields to be visible instead.
With this many possible criteria to choose from, how can I possibly
go wrong?

It's like I'm playing battleship, and I'm hitting all around the
right syntax without actually scoring.
 

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

Back
Top