Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabled VBA property use - Tab Control "On Change"

Status
Not open for further replies.

BGuidry

Technical User
Mar 18, 2009
28
US
I have a Tab Control, "TabCt", which includes two Tabs (aka Pages) containing
subforms(irrelevent though), "Tab1" and "Tab2". This is on a main form,
"Form1", which includes a text box "txtbox" (names for example only). I
would like to have the text box appear only when "Tab1" is selected/active,
but not for "Tab2". There are limited options in the event properties for
tab controls, so I have chosen to run the code (below) based on the 'On
Change' property. Currently, based on the code below, the text box
disappears when selecting either tab. I am reaching out for help in
adjusting my code (below) to work correctly. I am wondering if possibly the
code needs to be adjusted so that it is not tied to the 'On Change' tab
control property as well, but I do not know how to adjust it so. I read in
Help that the Enabled Property applies to Tab Control groups (therefore I
wonder if it cannot apply to individual tabs).

Private Sub TabCt_Change()
Dim txtbox As TextBox
Set txtbox= [Forms]![Form1]![txtbox] 'because it is on the main form

If Me!Tab2.Enabled Then
txtbox .Visible = False
Else
txtbox.Visible = True

End If
End Sub

 
How are ya BGuidry . . .

Try this in the [blue]On Change[/blue] event instead:
Code:
[blue]   If Me![[purple][b][i]TabCtlName[/i][/b][/purple]] = 0 Then
      Me!Txt1.Visible = True
   Else
      Me!Txt1.Visible = False
   End If[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Yes Sir,

that worked...

So what does it mean to have the Tab Control = 0? I don't understand what this does?

Thanks very much!
 
what does it mean to have the Tab Control = 0
You're on the 1st page.
 
Oh, so "0" represents the first page in the Tab Control? And, therefore, if you would replace with 1, 2, etc., will it work then for each of the consecutive pages/tabs on the tab control?

Thanks again!
 
BGuidry . . .

Yes! ... [blue]Tab index starts at zero.[/blue]

BTW: Welcome to [blue]Tek-Tips![/blue] [thumbsup2] Do have a look at one of the links at the bottom of my post. The links will help you [blue]ask better questions[/blue], get [blue]quick responses[/blue], [blue]better answers[/blue], and insite into [blue]etiquette[/blue] here in the forums. Again . . . Welcome to [blue]Tek-Tips![/blue] [thumbsup2] [blue]Its Worthy Reading![/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top