Home All Groups Group Topic Archive Search About

Tab Change Passwords

Author
3 Dec 2006 2:36 AM
Roger Bell
I have written an OnChange Event procedure in the properties of a Control Tab
as follows: This works fine for the Tabctrl Page 7, but does not work for the
Page 4.
Could anyone please tell me where I have gone wrong?
Thanks for any help

Private Sub TabCtl0_Change()
    rctMask.Visible = True ' Mask page 7
    If Me!TabCtl0 = 7 Then
        If Not InputBox("Please Enter Password") = "roger" Then
            Me!TabCtl0 = 0
            MsgBox "Sorry, Incorrect Password"

        Else
            'show the tab page
            rctMask.Visible = False
        End If
            rctMask1.Visible = True ' Mask page 4
    If Me!TabCtl0 = 4 Then
        If Not InputBox("Please Enter Password") = "roger" Then
            Me!TabCtl0 = 0
            MsgBox "Sorry, Incorrect Password"

        Else
            'show the tab page
            rctMask1.Visible = False
        End If

    End If
    End If
End Sub

Author
3 Dec 2006 2:57 AM
tina
well, you don't say *how* it's gone wrong - is tab page 4 always hidden or
always visible? i assume that rctMask and rctMask1 are Rectangle controls
that you show/hide to cover/uncover the "contents" of the tab pages,
correct? so if the user is on tabpage 1, and moves to page 7, s/he must
enter the correct password to see what's on page 7; then if the user moves
to page 4, s/he must again enter the same password to see what's on page 4.
if the preceding is correct, then i don't see anything wrong with the code,
as far as it goes. are you sure rctMask1 is "sitting" on tab page 4, and not
behind the tab control? are you sure you're using the correct name of the
Rectangle control?

but suggest you give some thought to whether this is the best way to set up
your tab control. entering the same password over and over again, every time
they move to one of those two pages, is going to irritate your users to
death, hon.

as an alternative, you might try the following:  get rid of the Rectangle
controls entirely. set the Visible property of tab pages 4 and 7 to False in
form Design view. then add a command button to the form, perhaps labeled
"Show All", or "Admin", or "Managers" - whatever is appropriate. add code to
the command button to show the hidden tab pages when the proper password is
provided, as

Private Sub cmdShow_Click()

    If InputBox("Please enter password") = "roger" Then
        Me!TabPage4.Visible = True
        Me!TabPage7.Visible = True
    Else
        Msgbox "Sorry, incorrect password entered."
    End If

End Sub

once the correct password is entered, those two tab pages are available to
the user as long as the form is open. each time the form is re-opened, the
pages are again hidden until the password is provided.

hth


Show quoteHide quote
"Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
news:F24D7F1F-BA1D-4636-B661-B4401A5E45B8@microsoft.com...
> I have written an OnChange Event procedure in the properties of a Control
Tab
> as follows: This works fine for the Tabctrl Page 7, but does not work for
the
> Page 4.
> Could anyone please tell me where I have gone wrong?
> Thanks for any help
>
> Private Sub TabCtl0_Change()
>     rctMask.Visible = True ' Mask page 7
>     If Me!TabCtl0 = 7 Then
>         If Not InputBox("Please Enter Password") = "roger" Then
>             Me!TabCtl0 = 0
>             MsgBox "Sorry, Incorrect Password"
>
>         Else
>             'show the tab page
>             rctMask.Visible = False
>         End If
>             rctMask1.Visible = True ' Mask page 4
>     If Me!TabCtl0 = 4 Then
>         If Not InputBox("Please Enter Password") = "roger" Then
>             Me!TabCtl0 = 0
>             MsgBox "Sorry, Incorrect Password"
>
>         Else
>             'show the tab page
>             rctMask1.Visible = False
>         End If
>
>     End If
>     End If
> End Sub
>
Author
3 Dec 2006 6:31 AM
Roger Bell
Thanks so much, Tina for your comprehensive reply.
The Password is requested when you go to Tabe Page 7 with no problems.
When you go to Tab Page 4, the Dialogue box for the Password does not appear
and the user goes to Page 4 which is covered by the Mask.

Tab page 4 is always visible. I have double checked the names of the
Rectangle Controls. The rctMask & rctMask1 are Rectangle controls.  How would
I know for sure that rctMask1 is "sitting" on Tab Page 4? I assume it is, as
the fields are hidden when you click on this Tab. These Tabs are very rarely
used.
Is there anywhere else I may have gone wrong?
Thanks again for your valuable time

Show quoteHide quote
"tina" wrote:

> well, you don't say *how* it's gone wrong - is tab page 4 always hidden or
> always visible? i assume that rctMask and rctMask1 are Rectangle controls
> that you show/hide to cover/uncover the "contents" of the tab pages,
> correct? so if the user is on tabpage 1, and moves to page 7, s/he must
> enter the correct password to see what's on page 7; then if the user moves
> to page 4, s/he must again enter the same password to see what's on page 4.
> if the preceding is correct, then i don't see anything wrong with the code,
> as far as it goes. are you sure rctMask1 is "sitting" on tab page 4, and not
> behind the tab control? are you sure you're using the correct name of the
> Rectangle control?
>
> but suggest you give some thought to whether this is the best way to set up
> your tab control. entering the same password over and over again, every time
> they move to one of those two pages, is going to irritate your users to
> death, hon.
>
> as an alternative, you might try the following:  get rid of the Rectangle
> controls entirely. set the Visible property of tab pages 4 and 7 to False in
> form Design view. then add a command button to the form, perhaps labeled
> "Show All", or "Admin", or "Managers" - whatever is appropriate. add code to
> the command button to show the hidden tab pages when the proper password is
> provided, as
>
> Private Sub cmdShow_Click()
>
>     If InputBox("Please enter password") = "roger" Then
>         Me!TabPage4.Visible = True
>         Me!TabPage7.Visible = True
>     Else
>         Msgbox "Sorry, incorrect password entered."
>     End If
>
> End Sub
>
> once the correct password is entered, those two tab pages are available to
> the user as long as the form is open. each time the form is re-opened, the
> pages are again hidden until the password is provided.
>
> hth
>
>
> "Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
> news:F24D7F1F-BA1D-4636-B661-B4401A5E45B8@microsoft.com...
> > I have written an OnChange Event procedure in the properties of a Control
> Tab
> > as follows: This works fine for the Tabctrl Page 7, but does not work for
> the
> > Page 4.
> > Could anyone please tell me where I have gone wrong?
> > Thanks for any help
> >
> > Private Sub TabCtl0_Change()
> >     rctMask.Visible = True ' Mask page 7
> >     If Me!TabCtl0 = 7 Then
> >         If Not InputBox("Please Enter Password") = "roger" Then
> >             Me!TabCtl0 = 0
> >             MsgBox "Sorry, Incorrect Password"
> >
> >         Else
> >             'show the tab page
> >             rctMask.Visible = False
> >         End If
> >             rctMask1.Visible = True ' Mask page 4
> >     If Me!TabCtl0 = 4 Then
> >         If Not InputBox("Please Enter Password") = "roger" Then
> >             Me!TabCtl0 = 0
> >             MsgBox "Sorry, Incorrect Password"
> >
> >         Else
> >             'show the tab page
> >             rctMask1.Visible = False
> >         End If
> >
> >     End If
> >     End If
> > End Sub
> >
>
>
>
Author
3 Dec 2006 7:06 AM
Roger Bell
Sorry, Tina
Please ignore my previous correspondence.  I actually figured it out. I
needed 2 "End If" statements afer the first If.
Thanks again for your help

Show quoteHide quote
"tina" wrote:

> well, you don't say *how* it's gone wrong - is tab page 4 always hidden or
> always visible? i assume that rctMask and rctMask1 are Rectangle controls
> that you show/hide to cover/uncover the "contents" of the tab pages,
> correct? so if the user is on tabpage 1, and moves to page 7, s/he must
> enter the correct password to see what's on page 7; then if the user moves
> to page 4, s/he must again enter the same password to see what's on page 4.
> if the preceding is correct, then i don't see anything wrong with the code,
> as far as it goes. are you sure rctMask1 is "sitting" on tab page 4, and not
> behind the tab control? are you sure you're using the correct name of the
> Rectangle control?
>
> but suggest you give some thought to whether this is the best way to set up
> your tab control. entering the same password over and over again, every time
> they move to one of those two pages, is going to irritate your users to
> death, hon.
>
> as an alternative, you might try the following:  get rid of the Rectangle
> controls entirely. set the Visible property of tab pages 4 and 7 to False in
> form Design view. then add a command button to the form, perhaps labeled
> "Show All", or "Admin", or "Managers" - whatever is appropriate. add code to
> the command button to show the hidden tab pages when the proper password is
> provided, as
>
> Private Sub cmdShow_Click()
>
>     If InputBox("Please enter password") = "roger" Then
>         Me!TabPage4.Visible = True
>         Me!TabPage7.Visible = True
>     Else
>         Msgbox "Sorry, incorrect password entered."
>     End If
>
> End Sub
>
> once the correct password is entered, those two tab pages are available to
> the user as long as the form is open. each time the form is re-opened, the
> pages are again hidden until the password is provided.
>
> hth
>
>
> "Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
> news:F24D7F1F-BA1D-4636-B661-B4401A5E45B8@microsoft.com...
> > I have written an OnChange Event procedure in the properties of a Control
> Tab
> > as follows: This works fine for the Tabctrl Page 7, but does not work for
> the
> > Page 4.
> > Could anyone please tell me where I have gone wrong?
> > Thanks for any help
> >
> > Private Sub TabCtl0_Change()
> >     rctMask.Visible = True ' Mask page 7
> >     If Me!TabCtl0 = 7 Then
> >         If Not InputBox("Please Enter Password") = "roger" Then
> >             Me!TabCtl0 = 0
> >             MsgBox "Sorry, Incorrect Password"
> >
> >         Else
> >             'show the tab page
> >             rctMask.Visible = False
> >         End If
> >             rctMask1.Visible = True ' Mask page 4
> >     If Me!TabCtl0 = 4 Then
> >         If Not InputBox("Please Enter Password") = "roger" Then
> >             Me!TabCtl0 = 0
> >             MsgBox "Sorry, Incorrect Password"
> >
> >         Else
> >             'show the tab page
> >             rctMask1.Visible = False
> >         End If
> >
> >     End If
> >     End If
> > End Sub
> >
>
>
>
Author
3 Dec 2006 3:02 PM
tina
ah, very good. are you compiling your VBA code as you write it, Roger? a
compile would have caught the missing End If immediately, so it's a good
habit to get into doing it. i compile my code every time i make a change,
usually before i move from the procedure, but always before i leave the VBA
Editor window.

hth


Show quoteHide quote
"Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
news:6E9082F8-979E-45CF-809E-A2EC923A6334@microsoft.com...
> Sorry, Tina
> Please ignore my previous correspondence.  I actually figured it out. I
> needed 2 "End If" statements afer the first If.
> Thanks again for your help
>
> "tina" wrote:
>
> > well, you don't say *how* it's gone wrong - is tab page 4 always hidden
or
> > always visible? i assume that rctMask and rctMask1 are Rectangle
controls
> > that you show/hide to cover/uncover the "contents" of the tab pages,
> > correct? so if the user is on tabpage 1, and moves to page 7, s/he must
> > enter the correct password to see what's on page 7; then if the user
moves
> > to page 4, s/he must again enter the same password to see what's on page
4.
> > if the preceding is correct, then i don't see anything wrong with the
code,
> > as far as it goes. are you sure rctMask1 is "sitting" on tab page 4, and
not
> > behind the tab control? are you sure you're using the correct name of
the
> > Rectangle control?
> >
> > but suggest you give some thought to whether this is the best way to set
up
> > your tab control. entering the same password over and over again, every
time
> > they move to one of those two pages, is going to irritate your users to
> > death, hon.
> >
> > as an alternative, you might try the following:  get rid of the
Rectangle
> > controls entirely. set the Visible property of tab pages 4 and 7 to
False in
> > form Design view. then add a command button to the form, perhaps labeled
> > "Show All", or "Admin", or "Managers" - whatever is appropriate. add
code to
> > the command button to show the hidden tab pages when the proper password
is
> > provided, as
> >
> > Private Sub cmdShow_Click()
> >
> >     If InputBox("Please enter password") = "roger" Then
> >         Me!TabPage4.Visible = True
> >         Me!TabPage7.Visible = True
> >     Else
> >         Msgbox "Sorry, incorrect password entered."
> >     End If
> >
> > End Sub
> >
> > once the correct password is entered, those two tab pages are available
to
> > the user as long as the form is open. each time the form is re-opened,
the
> > pages are again hidden until the password is provided.
> >
> > hth
> >
> >
> > "Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
> > news:F24D7F1F-BA1D-4636-B661-B4401A5E45B8@microsoft.com...
> > > I have written an OnChange Event procedure in the properties of a
Control
> > Tab
> > > as follows: This works fine for the Tabctrl Page 7, but does not work
for
> > the
> > > Page 4.
> > > Could anyone please tell me where I have gone wrong?
> > > Thanks for any help
> > >
> > > Private Sub TabCtl0_Change()
> > >     rctMask.Visible = True ' Mask page 7
> > >     If Me!TabCtl0 = 7 Then
> > >         If Not InputBox("Please Enter Password") = "roger" Then
> > >             Me!TabCtl0 = 0
> > >             MsgBox "Sorry, Incorrect Password"
> > >
> > >         Else
> > >             'show the tab page
> > >             rctMask.Visible = False
> > >         End If
> > >             rctMask1.Visible = True ' Mask page 4
> > >     If Me!TabCtl0 = 4 Then
> > >         If Not InputBox("Please Enter Password") = "roger" Then
> > >             Me!TabCtl0 = 0
> > >             MsgBox "Sorry, Incorrect Password"
> > >
> > >         Else
> > >             'show the tab page
> > >             rctMask1.Visible = False
> > >         End If
> > >
> > >     End If
> > >     End If
> > > End Sub
> > >
> >
> >
> >
Author
4 Dec 2006 12:47 AM
Roger Bell
I guess I have been a litlle slack in that regard, Tina
Thanks for your advice and all your patience and help

Show quoteHide quote
"tina" wrote:

> ah, very good. are you compiling your VBA code as you write it, Roger? a
> compile would have caught the missing End If immediately, so it's a good
> habit to get into doing it. i compile my code every time i make a change,
> usually before i move from the procedure, but always before i leave the VBA
> Editor window.
>
> hth
>
>
> "Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
> news:6E9082F8-979E-45CF-809E-A2EC923A6334@microsoft.com...
> > Sorry, Tina
> > Please ignore my previous correspondence.  I actually figured it out. I
> > needed 2 "End If" statements afer the first If.
> > Thanks again for your help
> >
> > "tina" wrote:
> >
> > > well, you don't say *how* it's gone wrong - is tab page 4 always hidden
> or
> > > always visible? i assume that rctMask and rctMask1 are Rectangle
> controls
> > > that you show/hide to cover/uncover the "contents" of the tab pages,
> > > correct? so if the user is on tabpage 1, and moves to page 7, s/he must
> > > enter the correct password to see what's on page 7; then if the user
> moves
> > > to page 4, s/he must again enter the same password to see what's on page
> 4.
> > > if the preceding is correct, then i don't see anything wrong with the
> code,
> > > as far as it goes. are you sure rctMask1 is "sitting" on tab page 4, and
> not
> > > behind the tab control? are you sure you're using the correct name of
> the
> > > Rectangle control?
> > >
> > > but suggest you give some thought to whether this is the best way to set
> up
> > > your tab control. entering the same password over and over again, every
> time
> > > they move to one of those two pages, is going to irritate your users to
> > > death, hon.
> > >
> > > as an alternative, you might try the following:  get rid of the
> Rectangle
> > > controls entirely. set the Visible property of tab pages 4 and 7 to
> False in
> > > form Design view. then add a command button to the form, perhaps labeled
> > > "Show All", or "Admin", or "Managers" - whatever is appropriate. add
> code to
> > > the command button to show the hidden tab pages when the proper password
> is
> > > provided, as
> > >
> > > Private Sub cmdShow_Click()
> > >
> > >     If InputBox("Please enter password") = "roger" Then
> > >         Me!TabPage4.Visible = True
> > >         Me!TabPage7.Visible = True
> > >     Else
> > >         Msgbox "Sorry, incorrect password entered."
> > >     End If
> > >
> > > End Sub
> > >
> > > once the correct password is entered, those two tab pages are available
> to
> > > the user as long as the form is open. each time the form is re-opened,
> the
> > > pages are again hidden until the password is provided.
> > >
> > > hth
> > >
> > >
> > > "Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
> > > news:F24D7F1F-BA1D-4636-B661-B4401A5E45B8@microsoft.com...
> > > > I have written an OnChange Event procedure in the properties of a
> Control
> > > Tab
> > > > as follows: This works fine for the Tabctrl Page 7, but does not work
> for
> > > the
> > > > Page 4.
> > > > Could anyone please tell me where I have gone wrong?
> > > > Thanks for any help
> > > >
> > > > Private Sub TabCtl0_Change()
> > > >     rctMask.Visible = True ' Mask page 7
> > > >     If Me!TabCtl0 = 7 Then
> > > >         If Not InputBox("Please Enter Password") = "roger" Then
> > > >             Me!TabCtl0 = 0
> > > >             MsgBox "Sorry, Incorrect Password"
> > > >
> > > >         Else
> > > >             'show the tab page
> > > >             rctMask.Visible = False
> > > >         End If
> > > >             rctMask1.Visible = True ' Mask page 4
> > > >     If Me!TabCtl0 = 4 Then
> > > >         If Not InputBox("Please Enter Password") = "roger" Then
> > > >             Me!TabCtl0 = 0
> > > >             MsgBox "Sorry, Incorrect Password"
> > > >
> > > >         Else
> > > >             'show the tab page
> > > >             rctMask1.Visible = False
> > > >         End If
> > > >
> > > >     End If
> > > >     End If
> > > > End Sub
> > > >
> > >
> > >
> > >
>
>
>
Author
4 Dec 2006 2:36 AM
tina
you're welcome  :)


Show quoteHide quote
"Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
news:22BF541A-F5D3-45B8-874B-FB4206D39B5B@microsoft.com...
> I guess I have been a litlle slack in that regard, Tina
> Thanks for your advice and all your patience and help
>
> "tina" wrote:
>
> > ah, very good. are you compiling your VBA code as you write it, Roger? a
> > compile would have caught the missing End If immediately, so it's a good
> > habit to get into doing it. i compile my code every time i make a
change,
> > usually before i move from the procedure, but always before i leave the
VBA
> > Editor window.
> >
> > hth
> >
> >
> > "Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
> > news:6E9082F8-979E-45CF-809E-A2EC923A6334@microsoft.com...
> > > Sorry, Tina
> > > Please ignore my previous correspondence.  I actually figured it out.
I
> > > needed 2 "End If" statements afer the first If.
> > > Thanks again for your help
> > >
> > > "tina" wrote:
> > >
> > > > well, you don't say *how* it's gone wrong - is tab page 4 always
hidden
> > or
> > > > always visible? i assume that rctMask and rctMask1 are Rectangle
> > controls
> > > > that you show/hide to cover/uncover the "contents" of the tab pages,
> > > > correct? so if the user is on tabpage 1, and moves to page 7, s/he
must
> > > > enter the correct password to see what's on page 7; then if the user
> > moves
> > > > to page 4, s/he must again enter the same password to see what's on
page
> > 4.
> > > > if the preceding is correct, then i don't see anything wrong with
the
> > code,
> > > > as far as it goes. are you sure rctMask1 is "sitting" on tab page 4,
and
> > not
> > > > behind the tab control? are you sure you're using the correct name
of
> > the
> > > > Rectangle control?
> > > >
> > > > but suggest you give some thought to whether this is the best way to
set
> > up
> > > > your tab control. entering the same password over and over again,
every
> > time
> > > > they move to one of those two pages, is going to irritate your users
to
> > > > death, hon.
> > > >
> > > > as an alternative, you might try the following:  get rid of the
> > Rectangle
> > > > controls entirely. set the Visible property of tab pages 4 and 7 to
> > False in
> > > > form Design view. then add a command button to the form, perhaps
labeled
> > > > "Show All", or "Admin", or "Managers" - whatever is appropriate. add
> > code to
> > > > the command button to show the hidden tab pages when the proper
password
> > is
> > > > provided, as
> > > >
> > > > Private Sub cmdShow_Click()
> > > >
> > > >     If InputBox("Please enter password") = "roger" Then
> > > >         Me!TabPage4.Visible = True
> > > >         Me!TabPage7.Visible = True
> > > >     Else
> > > >         Msgbox "Sorry, incorrect password entered."
> > > >     End If
> > > >
> > > > End Sub
> > > >
> > > > once the correct password is entered, those two tab pages are
available
> > to
> > > > the user as long as the form is open. each time the form is
re-opened,
> > the
> > > > pages are again hidden until the password is provided.
> > > >
> > > > hth
> > > >
> > > >
> > > > "Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
> > > > news:F24D7F1F-BA1D-4636-B661-B4401A5E45B8@microsoft.com...
> > > > > I have written an OnChange Event procedure in the properties of a
> > Control
> > > > Tab
> > > > > as follows: This works fine for the Tabctrl Page 7, but does not
work
> > for
> > > > the
> > > > > Page 4.
> > > > > Could anyone please tell me where I have gone wrong?
> > > > > Thanks for any help
> > > > >
> > > > > Private Sub TabCtl0_Change()
> > > > >     rctMask.Visible = True ' Mask page 7
> > > > >     If Me!TabCtl0 = 7 Then
> > > > >         If Not InputBox("Please Enter Password") = "roger" Then
> > > > >             Me!TabCtl0 = 0
> > > > >             MsgBox "Sorry, Incorrect Password"
> > > > >
> > > > >         Else
> > > > >             'show the tab page
> > > > >             rctMask.Visible = False
> > > > >         End If
> > > > >             rctMask1.Visible = True ' Mask page 4
> > > > >     If Me!TabCtl0 = 4 Then
> > > > >         If Not InputBox("Please Enter Password") = "roger" Then
> > > > >             Me!TabCtl0 = 0
> > > > >             MsgBox "Sorry, Incorrect Password"
> > > > >
> > > > >         Else
> > > > >             'show the tab page
> > > > >             rctMask1.Visible = False
> > > > >         End If
> > > > >
> > > > >     End If
> > > > >     End If
> > > > > End Sub
> > > > >
> > > >
> > > >
> > > >
> >
> >
> >