stevensont
asked on
Password Protection Switchboard Option
Hi all:
I'm working to modify the switchboard logic to add a password function to an Admin option off of the main switchboard. These are the tricks: #1) I must use the switchboard and the switchboard manager; #2) the password, while entered, must not be shown (input mask = password); and #3) the code must integrate into the existing switchboard code and function with the switchboard manager.
The only way I know to satisfy trick #2 is to use a form. If it wasn't for that, this would be easy.
The idea is when a user clicks on the Admin button on the main switchboard a password form (Switchboard Access Form) would open prompting the user for the password. When a password is entered and the user clicks the OK button on the password form, the password form hide itself and the switchboard code validates the password. If valid, the switchboard logic continues by showing the Admin switchboard. If invalid, the user is given an error message with Yes or No buttons to continue. If the user clicks the Yes button, the switboard code would then go back to the password validation logic.
This is the code and the problem. The switchboard does not wait for the password to be entered (password form is a modal popup), it continue on its way while the password form hangs in the wings.
INFORMATIONAL: [Switchboard Access Form]![CmdButtonClick] is a text field on the password form that stores the value 1 if the OK button is clicked and 2 if the Cancel button is clicked.
__________
Const Pass0 = 0 ' Default
Const Pass1 = 1 ' Password Test Passed
Const Pass2 = 2 ' Msgbox NO to continue
Const Pass3 = 3 ' Cancel Button
Dim Result As Integer
Dim PassResult As Integer
PassResult = Pass0
If Me("Optionlabel" & intBtn).Caption = "&Admin. Switchboard" Then
DoCmd.OpenForm "Switchboard Access Form"
While PassResult = Pass0
If Forms![Switchboard Access Form]![CmdButtonClick] = 1 Then
If Forms![Switchboard Access Form]![TxtPassword] <> "Today" Then
Result = MsgBox("Invalid password. Do you want to try again?", _
vbYesNo + vbCritical, "Access Denied")
Select Case Result
Case vbYes
Forms![Switchboard Access Form].Visible = True
Case vbNo
PassResult = Pass2
End Select
Else
PassResult = Pass1
DoCmd.Close "Switchboard Access Form"
End If
Else
PassResult = Pass3
DoCmd.Close "Switchboard Access Form"
End If
Wend
End If
If PassResult = Pass2 Or _
PassResult = Pass3 Then
Exit Function
End If
I'm working to modify the switchboard logic to add a password function to an Admin option off of the main switchboard. These are the tricks: #1) I must use the switchboard and the switchboard manager; #2) the password, while entered, must not be shown (input mask = password); and #3) the code must integrate into the existing switchboard code and function with the switchboard manager.
The only way I know to satisfy trick #2 is to use a form. If it wasn't for that, this would be easy.
The idea is when a user clicks on the Admin button on the main switchboard a password form (Switchboard Access Form) would open prompting the user for the password. When a password is entered and the user clicks the OK button on the password form, the password form hide itself and the switchboard code validates the password. If valid, the switchboard logic continues by showing the Admin switchboard. If invalid, the user is given an error message with Yes or No buttons to continue. If the user clicks the Yes button, the switboard code would then go back to the password validation logic.
This is the code and the problem. The switchboard does not wait for the password to be entered (password form is a modal popup), it continue on its way while the password form hangs in the wings.
INFORMATIONAL: [Switchboard Access Form]![CmdButtonClick] is a text field on the password form that stores the value 1 if the OK button is clicked and 2 if the Cancel button is clicked.
__________
Const Pass0 = 0 ' Default
Const Pass1 = 1 ' Password Test Passed
Const Pass2 = 2 ' Msgbox NO to continue
Const Pass3 = 3 ' Cancel Button
Dim Result As Integer
Dim PassResult As Integer
PassResult = Pass0
If Me("Optionlabel" & intBtn).Caption = "&Admin. Switchboard" Then
DoCmd.OpenForm "Switchboard Access Form"
While PassResult = Pass0
If Forms![Switchboard Access Form]![CmdButtonClick] = 1 Then
If Forms![Switchboard Access Form]![TxtPassword] <> "Today" Then
Result = MsgBox("Invalid password. Do you want to try again?", _
vbYesNo + vbCritical, "Access Denied")
Select Case Result
Case vbYes
Forms![Switchboard Access Form].Visible = True
Case vbNo
PassResult = Pass2
End Select
Else
PassResult = Pass1
DoCmd.Close "Switchboard Access Form"
End If
Else
PassResult = Pass3
DoCmd.Close "Switchboard Access Form"
End If
Wend
End If
If PassResult = Pass2 Or _
PassResult = Pass3 Then
Exit Function
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER