Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Protect Tabs on Forms!

Status
Not open for further replies.

TheTomCat

Programmer
Aug 25, 2004
73
US
I saw some code once about password protecting a Tab on a form. However, it says to place the code in the "On Change" event. I do NOT see an "On Change" event.
The code is:

Private Sub TabCtl0_Change()

Dim strInput As String
Dim ctl As Control

' Hide controls on tab until correct password is entered
For Each ctl In Controls
If ctl.Tag = "*" Then
ctl.Visible = False
End If
Next ctl

' If tab page with Tab Index of 1 is selected
' show InputBox asking for password
If TabCtl0.Value = 1 Then
strInput = InputBox("Please enter a password to access this tab", _
"Restricted Access")

' Check if value is entered into InputBox
' If no value entered display MsgBox
If strInput = "" Or strInput = Empty Then
MsgBox "No Input Provided", , "Required Data"
TabCtl0.Pages.Item(0).SetFocus
Exit Sub
End If

' Check InputBox value and if value is a match
' display tab and unhide hidden fields
If strInput = "password" Then

For Each ctl In Controls
If ctl.Tag = "*" Then
ctl.Visible = True
End If
Next ctl
' If incorrect password supplied return to tab (index 0)
Else
MsgBox ("Sorry, you do not have access to this information")
TabCtl0.Pages.Item(0).SetFocus

Exit Sub
End If
End If

End Sub


Any suggestions?


Thomas Bailey
a/k/a TomCat
 
Hi
If you click slightly to the right of the tabs, WILL select the complete tab control, you will then see the properties for it.
Hope this helps
darin
 
GREAt, that works. I actually had to play with it a little. I had better success clicking at the top and to the the right of the tab itself.

Anyway, Thanks for the tip. I never would have guessed that.



Thomas Bailey
a/k/a TomCat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top