Solved

Tab Control - On Click Event Page !

Posted on 2001-07-19
10
173 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 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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 …

856 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