Hello All,
I have a hidden form that loads when the database is open that has a few events on the Form_Load event (see below). So far, the code is working great. It does exactly what I need and then some but I would like to have an additional event that checks the username in the "tblCurrentlyLoggedIn" and will log-off the previous instance or prompt the user to log-off the other instance 1st. Any help would be greatly appreciated, thank you in advance!
Private Sub Form_Load()
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblCurrentlyLoggedIn ( empCurrentlyLoggedIn ) " & _
"SELECT CurrentUser() AS Users;"
DoCmd.SetWarnings True
Set rs = CurrentDb.OpenRecordset("SELECT * FROM ButtonClicks")
rs.AddNew
rs![ButtonClick] = "User Log-In"
rs![ClickTime] = Time()
rs![ClickDate] = Date
rs![User] = CurrentUser()
rs![SearchInput] = Environ("Computername")
rs.Update
rs.Close
Set rs = Nothing
If Me.Send = -1 And Me.User = "All Users" Then
Me.Visible = True
ElseIf Me.Send = "-1" And Me.Shutdown = "0" And Me.User = CurrentUser() Then
Me.Visible = True
ElseIf Me.Send = "-1" And Me.Shutdown = "-1" And Me.User = CurrentUser() Or Me.User = "All Users" Then
Me.Visible = True
DoCmd.Quit acQuitSaveAll
Else
Me.Visible = False
End If
End If
End Sub
I have a hidden form that loads when the database is open that has a few events on the Form_Load event (see below). So far, the code is working great. It does exactly what I need and then some but I would like to have an additional event that checks the username in the "tblCurrentlyLoggedIn" and will log-off the previous instance or prompt the user to log-off the other instance 1st. Any help would be greatly appreciated, thank you in advance!
Private Sub Form_Load()
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblCurrentlyLoggedIn ( empCurrentlyLoggedIn ) " & _
"SELECT CurrentUser() AS Users;"
DoCmd.SetWarnings True
Set rs = CurrentDb.OpenRecordset("SELECT * FROM ButtonClicks")
rs.AddNew
rs![ButtonClick] = "User Log-In"
rs![ClickTime] = Time()
rs![ClickDate] = Date
rs![User] = CurrentUser()
rs![SearchInput] = Environ("Computername")
rs.Update
rs.Close
Set rs = Nothing
If Me.Send = -1 And Me.User = "All Users" Then
Me.Visible = True
ElseIf Me.Send = "-1" And Me.Shutdown = "0" And Me.User = CurrentUser() Then
Me.Visible = True
ElseIf Me.Send = "-1" And Me.Shutdown = "-1" And Me.User = CurrentUser() Or Me.User = "All Users" Then
Me.Visible = True
DoCmd.Quit acQuitSaveAll
Else
Me.Visible = False
End If
End If
End Sub