Solved

Tab Control - On Click Event Page !

Posted on 2001-07-19
10
169 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
Comment Utility
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 100 total points
Comment Utility
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
Comment Utility
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
 
LVL 12

Expert Comment

by:Paurths
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 12

Expert Comment

by:Paurths
Comment Utility
hi ImraneA ,

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

cheers
Ricky
0
 
LVL 12

Expert Comment

by:Paurths
Comment Utility
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
Comment Utility
instead of the 'onClick'-event?
0
 
LVL 12

Expert Comment

by:Paurths
Comment Utility
just as i thought
0
 

Author Comment

by:ImraneA
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now