Hi,
I'm trying to require a password using an input box in order to enter a form. I have a table listing the managers and passwords. I've pieced together some code. The problem is that it will only open for one manager. Any help is greatly appreciated.
Private Sub CmdOpen_FY_09_10_Forecast_Form_Click()
Dim Getpass As String
If IsNull(Me.cboManager) Or Me.cboManager = "" Then
MsgBox "You must select a Manager.", vbOKOnly
Cancel = True
Me.cboManager.SetFocus
ElseIf (Me.cboManager) & "" <> "" Then
Getpass = InputBox("Enter Password", "Please Enter Your Password")
If Getpass = DLookup("[Password]", "Managers", "Manager = '" & Me.cboManager & "'") Then
DoCmd.RunMacro "mcrOpen FY 09-10 Forecast", 1
Else 'password is incorrect
MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access.", vbCritical, "Invalid Password"
End If
End If
End Sub
I'm trying to require a password using an input box in order to enter a form. I have a table listing the managers and passwords. I've pieced together some code. The problem is that it will only open for one manager. Any help is greatly appreciated.
Private Sub CmdOpen_FY_09_10_Forecast_Form_Click()
Dim Getpass As String
If IsNull(Me.cboManager) Or Me.cboManager = "" Then
MsgBox "You must select a Manager.", vbOKOnly
Cancel = True
Me.cboManager.SetFocus
ElseIf (Me.cboManager) & "" <> "" Then
Getpass = InputBox("Enter Password", "Please Enter Your Password")
If Getpass = DLookup("[Password]", "Managers", "Manager = '" & Me.cboManager & "'") Then
DoCmd.RunMacro "mcrOpen FY 09-10 Forecast", 1
Else 'password is incorrect
MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access.", vbCritical, "Invalid Password"
End If
End If
End Sub