
Originally Posted by
pbaldy
Happy to help! I thought you wanted a list of the users, so it can be even simpler as you don't need the loop:
OOOOOOhhhh right. Thanks again for the assist. I am using this code as a checker to make sure no users are logged into the database before putting it down for maintenance. Okay revised final code is now:
Code:
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Select * FROM TblLogin WHERE [Login]=1 AND [statusCurrent]='Online')
'Check to see if the recordset actually contains rows
If Not (rst.EOF And rst.BOF) Then
MsgBox "There is another User Online." _
& vbCrLf & "Use Maintenance Shutdown to Log Off the Users.", vbInformation, "Information"
Else
CurrentDb.Properties("StartupForm") = "frmDbDown"
MsgBox "There are no other Users Online." _
& vbCrLf & "DB is down for Maintenance.", vbInformation, "Information."
Me.lblDBIS.Caption = "DB Is Currently DOWN"
rst.Close
Set rst = Nothing
Exit Sub
End If
rst.Close 'Close the recordset
Set rst = Nothing 'Clean Up
End Sub