Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Tab events (2003/2007)

    IS there a simple way that to see a prticular subform on a tab in main form, that when you click on the tab, you get a message box with a password to enter. (I know anyone who knows any VBA can defeat this in a second, but the point. This is the level of security/lack thereof that the people want.) Which of the events of the tab or the subform could I use? Maybe set all the controls on the subform to visible= false when clicking on the tab without the PW?
    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Tab events (2003/2007)

    You could use the On Change event of the tab control:

    Private Sub ctlTab_Change()
    Dim blnOK As Boolean
    If Me.ctlTab = 2 Then ' third tab, index starts at 0
    blnOK = (InputBox("Enter password") = "secret")
    Me.NameOfSubform.Visible = blnOK
    End If
    End Sub

    Of course, you must substitute the correct names and values.

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Tab events (2003/2007)

    I get an error that you cannot hide the control when it has the focus
    Any idea?
    Thanks as usual

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Tab events (2003/2007)

    Set the focus to another control on the tab page than the subform before hiding the subform. If the subform is the only control on the tab page, place a text box txtDummy with width and height 0 on the tab page and set focus to that:

    Private Sub ctlTab_Change()
    If Me.ctlTab = 2 Then ' third tab, index starts at 0
    If InputBox("Enter password") = "secret" Then
    Me.NameOfSubform.Visible = True
    Else
    Me.txtDummy.SetFocus
    Me.NameOfSubform.Visible = False
    End If
    End If
    End Sub

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Tab events (2003/2007)

    This is what I used:

    I set the controls as visible= false in the original design and then to open it I use the following code:

    Dim blnOK As Boolean
    Dim frm As Form
    Dim ctl As Control
    Set frm = Me!TblTeacherSalary.Form


    If Me.TabCtl52 = 1 Then
    blnOK = (InputBox("Enter password") = "secret")
    If blnOK = True Then

    For Each ctl In frm.Controls
    ctl.Visible = True

    Next
    End If

    End If


    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •