Enter password once for tabs (1 Viewer)

shatteras

Registered User.
Local time
Today, 01:56
Joined
Apr 11, 2016
Messages
25
hello again... please see the code below, purpose is to get a password for a certain tab. this example have 2 tabs, tab 1 requires password, tab 2 doesn't. I would like to know how to stop that tab from asking for a password once the authorized user entered it once. at least until he close the main form. thank you very much.

(the reason is, there will be more than 2 tabs. and the authorized user will be switching tabs often, and going back to tab 1 and entering the password over and over doesn't seem to be user friendly)



Private Sub MFTcontrolTAB1_Change()

Dim strInput As String
Dim ctl As Control

For Each ctl In Controls
If ctl.Tag = "*" Then
ctl.Visible = False
End If
Next ctl
If MFTcontrolTAB1.Value = 1 Then
strInput = InputBox("Please enter a password to access Operations", _"Restricted Access")

If strInput = "" Or strInput = Empty Then
MsgBox "No Input Provided", , "Required Data"
MFTcontrolTAB1.Pages.Item(0).SetFocus
Exit Sub
End If
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 are not allowed to access this tab")
MFTcontrolTAB1.Pages.Item(0).SetFocus

Exit Sub
End If
End If

End Sub

 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:56
Joined
May 7, 2009
Messages
19,169
create a form-wise variable and save the status of the tab there:

option compare database
option explicit

dim bolTab2Authorized As Boolean


If MFTcontrolTAB1.Value = 1 And Not bolTab2Authorized Then
strInput = InputBox("Please enter a password to access Operations", _"Restricted Access")
...
...

..then save the status


If strInput = "password" Then
bolTab2Authorized = True

'====

you can declare it formwise or projhect wise, depends on you.
 

Users who are viewing this thread

Top Bottom