Hi June7
Thank you for the reply. I thought that I might have to do that. Your solution worked perfectly.
For the future reference of other visitors, here is the code for the Login Screen sub.
Code:
Private Sub Command1_Click()
' Login Screen
If IsNull(Me.txtLoginID) Then
MsgBox "Please enter Login ID", vbInformation, "Login ID Required"
Me.txtLoginID.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter Login Password", vbInformation, "Login Password Required"
Me.txtPassword.SetFocus
Else
' Continue. Check that user exists.
If (IsNull(DLookup("WebUsername", "xEmployees", "StrComp(WebUsername, '" & Me.txtLoginID.Value & "', 0) = 0 AND StrComp(WebPassword, '" & Me.txtPassword.Value & "', 0) = 0"))) Then
MsgBox "Incorrect Login ID or Password", vbInformation, "Login Details Incorrect"
Else
'Continue and check that the user isn't already logged in on another terminal
LoginUserName = (DLookup("Firstname", "xEmployees", "WebUsername ='" & Me.txtLoginID.Value & "'")) & " " & (DLookup("Surname", "xEmployees", "WebUsername ='" & Me.txtLoginID.Value & "'"))
If DLookup("LoginUsername", "Logger", "LoginUsername = '" & LoginUserName & "'" & "AND IsNull([Logout])") > 0 Then
Dim OnComputer As String
OnComputer = DLookup("ComputerName", "Logger", "LoginUserName='" & LoginUserName & "' AND IsNull([Logout])")
MsgBox LoginUserName & " is already logged in on " & OnComputer & Chr(13) & "Program will now close.", vbInformation, "Login Error"
DoCmd.Quit
Else
'All good to proceed
AccessLvl = (DLookup("DBAccessLvl", "xEmployees", "WebUsername ='" & Me.txtLoginID.Value & "'"))
DoCmd.Close
MsgBox "Welcome " & LoginUserName & Chr(13) & "Access Level: " & AccessLvl, vbInformation, "Sucessfully Logged In"
DoCmd.Close
DoCmd.OpenForm "Main Screen"
End If
End If
End If
End Sub