Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 23rd, 2006, 08:36 AM
Authorized User
 
Join Date: Nov 2005
Posts: 41
Thanks: 6
Thanked 1 Time in 1 Post
Send a message via MSN to RobCarter
Default On_Click event of Tab Control

Hi. This is frustrating the hell out of me.

I am trying to use the on_click event of a tab control in order that a user must first authenticate themselves to view the second tab (which contains sensitive information).

I click on the tab in for the sensitive info in design view and use the on_click event to write my code. When I click on the tab in form view nothing happens. I put in a breakpoint to debug but it doesn't look like it's even calling my procedure.

I have 2 tabs: one called client details and one called sensitive information. Here is my code:

Private Sub Sensitive_information_Click()
    Dim strPassword As String
    Dim strEnterPassword As String
    Dim intPasswordCount As Integer

    intPasswordCount = 1

    strPassword = "cfspass"
    strEnterPassword = InputBox("Enter Password to view/add sensitive information", "Enter Password")

    Do While intPasswordCount <= 3
        If strPassword <> strEnterPassword Then
            MsgBox "You have entered an incorrect password. You have " & 3 - intPasswordCount & " attempts remaining.", vbRetryCancel + vbCritical, "Incorrect password"
            intPasswordCount = intPasswordCount + 1
        Else
            MsgBox "blah"
            intPasswordCount = 5
        End If
    Loop

End Sub

Now I'm not too bothered about the security issue of including the password in my code because I can sort that out later. I am more interested in hwy the code isn't being called.

Can someone please help?

Thanks
__________________
Rob Carter
 
Old October 23rd, 2006, 09:30 AM
Authorized User
 
Join Date: Nov 2005
Posts: 41
Thanks: 6
Thanked 1 Time in 1 Post
Send a message via MSN to RobCarter
Default

I have figured it out - Well i haven't I carried on looking for help and found this little gem:

 
Quote:
quote:Where exactly are you clicking? It may seem counter-intuitive, but the
Quote:
"tab" that you click on to change Tab Pages is not considered part of the
Tab Page so it doesn't fire the page's Click event. That fires when you
click on a blank area of the page *after* you have made that page the one
"on top".

If you want an event that fires when you change Tab Pages then you have to
use the Change event of the TabControl. To make that code "page specific"
you test the value property of the TabControl in the change event to
determine which page was just selected and run your code accordingly.
It was stored on this link (I don't know how permanent it will be)

http://www.thescripts.com/forum/thread191260.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable a tab on a tab control. dbradley VB.NET 6 April 14th, 2011 10:04 AM
tab control amey.agnihotri C# 2005 1 June 19th, 2007 04:10 AM
Calendar Control with Tab Control Slicemahn Access 1 June 12th, 2006 10:35 PM
Tab Control Bhanu .NET Framework 2.0 1 December 2nd, 2004 07:25 AM
Tab Key event ssrinivas VB How-To 5 November 4th, 2004 04:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.