?
Solved

Tab Control - On Click Event Page !

Posted on 2001-07-19
10
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

718 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