Create a textbox named txtUser on form Open Opportunities List. Set ControlSource to: = [OpenArgs]
Modify code in LoginForm to:
Code:
Private Sub Login_Click()
Dim uname As String
Dim sWHERE As String
If Me.UserNameTextBox & "" = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.UserNameTextBox.SetFocus
ElseIf Me.PasswordTextbox & "" = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.PasswordTextbox.SetFocus
ElseIf Me.PasswordTextbox <> Nz(DLookup("[Password]", "tblMasterusers", "[UserName]='" & Me.UserNameTextBox & "'"), "") _
Or Me.UserNameTextBox <> Nz(DLookup("[UserName]", "tblMasterusers", "[UserName]='" & Me.UserNameTextBox & "'"), "") Then
MsgBox "Please Enter Correct username and password"
Else
uname = Me.UserNameTextBox
If DLookup("[Usertype]", "tblMasterusers", "[UserName]='" & Me.UserNameTextBox & "'") <> "admin" Then
sWHERE = "[User Name] ='" & Me.UserNameTextBox & "'"
End If
DoCmd.Close
DoCmd.OpenForm "Open Opportunities List", acNormal, , sWHERE, , , uname
End If
End Sub