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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make cmdButton visible only when page2 is active 1

Status
Not open for further replies.

annie52

Technical User
Mar 13, 2009
164
US
I have a tab control with three pages containing subforms. On the main form, I have a command button that should only be visible when the second page is at the front. I'm not sure what event to use.
 



Me![[blue]ButtonName[/blue]].Visible = (Me![[blue]TabControlName[/blue]] = 1)

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Using aceman's code I would break it out and at minimum call it from the change event of the tab, but you may also need to call it from another event.

Private Sub TabCtl0_Change()
Call showHideButton
End Sub

Public Sub showHideButton()
Me.cmdOne.Visible = (Me.TabCtl0 = 1)
End Sub
 
annie52 . . .

I simply put the code in the controls change event:
Code:
[blue]Private Sub TabControlName_Change()
   Me!Command24.Visible = (Me!Tab1 = 1)
End Sub[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thank you both. I ended up using the control's Change event. Also, had to put the code in the Current event of the main form.
 
annie52 said:
[blue] ... Also, had to put the code in the Current event of the main form.[/blue]
Why? [surprise]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Because when I load the main form, page0 is at the front of the tab control (i.e., the change event hasn't occured yet) and I don't want the button visible at that point.
 
annie52 . . .

So in design view just set the buttons [blue]visible[/blue] property to [blue]No[/blue] . . .

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Of course that makes perfect sense. I was sure that I did that and it did not work. But, I just tried it again and, of course, you're right. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top