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

Disable Command Buttons 1

Status
Not open for further replies.

Cleis

Technical User
Jun 4, 2000
197
US
Group:

How would I disable a command button based on what page I'm on within a tab control? I have a series of cmd buttons across the bottom of the form (below the tab control).

Which event would I use on the Tab Control?


Thanks!
 
Thanks Zor!

Where do I put it? You cannot put this on the On-Click event of the page within the tab control. Further, I've not been able to figure out what the correct sytax should be on the Tab Control property sheet.

I'm assuming that I need to use an if then to determine which page within this tab control has the focus then insert your code.

Any ideas?
 
Each page of the tab control has its own properties. If in design mode you double click a tab, the properties window should open. In there you will see an onclick event. Clicking on the far right of the property line onclick should open a dialogue box. Select you want to insert code. You do not have to put any prefix of tab name with the control you are referring to enable or disable.
 
Okay folks now I'm confused! I have put the following "Me.cmdResetFilters.Enabled = False" on the "On-Click" event for individual page as well as the tabCtl itself. In both cases, it did not work? I even highlighted the code to see the value when the code steps through. You guessed it, the on-clik event didn't even recognize the break points???


Whats up with this???
 
Zor!

Thanks for taking the time to answer my question!! What a work around!! Although. . . . you have to admit, ya' should'nt hafta'!

Here is a star!
 
Always seems to the case, what should be easy isn't. I put it down to Microsofts humour. You might still be lucky and have someone else come in with an alternative. In my application using a tab control, I make all pages hidden except 1 on which I have menu command buttons. That way I can then open the page I want the user to see, and set any controls visible/enabled etc. Try to enjoy it all!!
 
Thats a little bit of overkill. Normally you want something to happen when you change a page. The value of the tab control is the page number - 1. So if you select the first page the value of the tab control is 0. So if you want something to happen when you click on a page this is an example to do this using the On Change event.

Code:
Private Sub TabCtl0_Change()
  Select Case TabCtl0.Value
  Case 0
    MsgBox "Page 1 Selected"
    'do some code here when page 1 selected'
  Case 1
    MsgBox "Page 2 Selected"
     'do some code here when page 2 selected'
  Case 2
    MsgBox "Page 3 selected"
    'do some code here when page 3 selected'
  End Select
End Sub

The thing to remember is that this is an on change event. So if the form opens on the first page and you click on the first page nothing happens because the value of the control did not change. However, if you go from page 2 to page 1 it will fire.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top