Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Tab Control - On Click Event Page !

Posted on 2001-07-19
10
Medium Priority
?
184 Views
Last Modified: 2008-03-06
Hi there

Background: - Main form has tab control, with 8 pages.  At the bottom of the Tab Control have 3 command buttons.

Trying to do: - Default page 1, wish 3 command buttons enabled.  Select any of other pages, 2 command buttons disabled.  

Tried(1): - On individual page, on click event entered code

    e.g. me.[name of control].enabled = true

or

    e.g. me.[name of control].enabled = false

Depending on page.

But nothing happened !
-
Investigated further, so tried stepping through code.  Nothing happened when I clicked on the page where the code was.

Bit of mystery.  

Where am I going wrong ????

Any ideas most welcome.  Thanks

Ideas: do i move the code to on_click event for tab control ? But, how do allow for on_click events for individual pages ?

 


0
Comment
Question by:ImraneA
10 Comments
 
LVL 7

Expert Comment

by:Nosterdamus
ID: 6297392
Hi Imranea,

In order for the button(s) to be a available in each page seperatly, you have to put it (them) in the page itself (rather then putting it in the form).

This way, you should insert 17 defferent buttons (3 for the first page, and 2 for each of the other 7 pages).

Now, no code in necessary to control the buttons visibility.

Hope this helps,

Nosterdamus
0
 
LVL 7

Accepted Solution

by:
Jonathan Kelly earned 400 total points
ID: 6297427
i had a very similar problem recently.
i could not get the page on click event to fire except when you click the page in certain places, 1 of which was not on the Page Title.

I needed to run a process from outside the Tab Control but i needed to know which page was active. To achieve this i used TabControlName.Value to return the number of the current tab and an if statment to determine the name later.

e.g.

run myProcess
x = TabCtlName.Value 'Current Page
if x = 0 then theCurrentPage = "Page1"
if x = 1 the theCurrentPage = "Page2"
etct etc.....

is this any help ?
datrias
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6297456
hi

here  is an example of how u can know what page the user selects: (in this example i named the tab control 'MyTab')

Private Sub MyTab_Change()
    MsgBox "U selected tab # : " MyTab.Value & ", the name of the page is : " & MyTab.Pages(MyTab.Value).Name
End Sub

cheers
Ricky
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 12

Expert Comment

by:Paurths
ID: 6297463
oops, forgot a concatenation-mark

MsgBox "U selected tab # : " & MyTab.Value & ", the name of the page is : " & MyTab.Pages(MyTab.Value).Name


anyway, now u can use a 'select case' statement:


Private Sub MyTab_Change()
Select case Mytab.value
  case 0 'User selects first page
    Button1.enabled = true
    Button2.enabled = true
    Button3.enabled = false
  case 1 'user selects second page
    Button1.enabled = false
    Button2.enabled = true
    Button3.enabled = true
end select
end sub



hope this helps,
Ricky
0
 

Author Comment

by:ImraneA
ID: 6298110
Spot on - excellent .  Thanks

sample of code

On Error GoTo Err_TabControl_Change
   
    Dim x As Integer
    Dim db As Database, rs1 As Recordset, rs2 As  Recordset, rs3 As Recordset
    Dim intAnswer As Integer
    Dim strSQL As String, strSQL1 As String, strSQL2 As String
    Dim qdf As QueryDef
   
    x = Me.TabControl.Value
   
    '***AIM-Pages
    If x = "0" Then
        '***AIM-Controls
        Me.cmdProj_Mgr.Visible = True
        Me.cmdPreview_Report.Visible = True
        If Me.ResultOfAction = "1" Or Me.ResultOfAction = "5" Then
            Me!cmdImp_Dis.Enabled = True
        End If
        If Me.ResultOfAction = "2" Or Me.ResultOfAction = "3" Or Me.ResultOfAction = "4" Then
            Me!cmdImp_Dis.Enabled = False
        End If
    ElseIf x = "1" Then
        Me.cmdProj_Mgr.Visible = False
        Me.cmdImp_Dis.Visible = False
        Me.cmdPreview_Report.Visible = True
    ElseIf x = "2" Then
   
    ....

   
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6298145
hi ImraneA ,

where exactly did datrias point u to the 'Tab control Change'- event ?

cheers
Ricky
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6298349
in fact, did any of u know that it was the onChange-event that is to be used?
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6298352
instead of the 'onClick'-event?
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6300400
just as i thought
0
 

Author Comment

by:ImraneA
ID: 6301592
Hi there

Main reason I gave datrias points -- >

"I needed to run a process from outside the Tab Control but i needed to know which page was active. To
achieve this i used TabControlName.Value to return the number of the current tab and an if statment
to determine the name later.".

Then I figured out the rest.  Tried on- click event but that did not work so tried on change.  That worked.

Imrane.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question