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

Enable command button based on selected tab page

Status
Not open for further replies.

mrbboy

Technical User
Feb 28, 2007
136
US
I have a form that has 5 tab pages. There is also a command button on the form, cmd_Submit. Is it possible to enable/disable the command button, cmd_Submit, based on which tab page is selected? I tried placing the code in the On Click event of a tab (say Tab 2) but it didn'd do anything to cmd_Submit.

Me.cmd_Submit.Enabled = False
 
The first thing to understand is that tabbed pages are indexed starting with zero, i.e. the first page has a value of 0, second page has a value of 1, third page has a value of 2, etc. So to do something if the 2nd tabbed page is moved to, you have to use Me.YourTabbedControl.Value = 1.

Secondly, you need to understand that the OnClick event of a tabbed page only fires when you click on the page itself, not the tab at the top of the page!

Lastly, you need to understand that the tabbed control change event fires anytime the tabbed pages change. But to base something on the change event, you have to identify the particular page that has focus.


Code:
Private Sub YourTabbedControl_Change()
If Me.YourTabbedControl.Value = 1 Then ‘2nd Page
  cmd_Submit.Enabled = True
Else
  cmd_Submit.Enabled = False
End If
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top