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
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.