Solved

Tab Control - On Click Event Page !

Posted on 2001-07-19
10
175 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 100 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 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