S
shangman via AccessMonster.com
In a form in which i have restricted access to a tab, users need to enter a
password to enter. This works fine (this code and put it into the "onchange"
section of the tab). But what i can't figure out is how to make a password
for this. I am still learning in access and would appreciate any help on how
to do this.
(code example is listed)
Private Sub TabCtl20_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 6 is selected
' show InputBox asking for password
If TabCtl20.Value = 6 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"
TabCtl20.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")
TabCtl20.Pages.Item(0).SetFocus
Exit Sub
End If
End If
End Sub
password to enter. This works fine (this code and put it into the "onchange"
section of the tab). But what i can't figure out is how to make a password
for this. I am still learning in access and would appreciate any help on how
to do this.
(code example is listed)
Private Sub TabCtl20_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 6 is selected
' show InputBox asking for password
If TabCtl20.Value = 6 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"
TabCtl20.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")
TabCtl20.Pages.Item(0).SetFocus
Exit Sub
End If
End If
End Sub