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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password for a tab on a Form

Status
Not open for further replies.

hobman

Vendor
Sep 8, 2004
39
US
Sorry but I can't use the search feature since it is out of service right now.

Is there a way I can password protect a specific tab on a Form?

thanks in advance
 
Here is a simple way. Depends on how elaborate you want to get.

This example keeps you off the second page.

Dim strPassWord As String

Private Sub TabCtl0_Change()
If Me.TabCtl0.Value = 1 And strPassWord <> "YourPass" Then
strPassWord = InputBox("Enter Password", "Password")
If strPassWord <> "YourPass" Then
Me.TabCtl0.Value = 0
MsgBox "Not authorized"
End If
End If
End Sub
 
Thank you so much MajP. not to sound stupid but I was wondering, where should the password be? thanks again.
 
I hard coded the password into the If statement. You may want to put it in a table somewhere so that it can be easily changed by an administrator, and you do not have to rewrite the code. use can then use a Dlookup to return the password from the table and compare it to the value of the inputbox. Assuming that you lock the database down. You could also check the password when the form opens and hide the page altogether.

One thing that gets people on tab controls is that the click event for a page does not do what you think. If you click the tab, and you want to check something you use the tab control change event and check the value of the tab control.
If you click on the first tab the value of the control is zero, if you click the second tab the value of the control is 1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top