LogUsersOff

S

Swordfish

I came across this old coding that when you change the value of Logoff in the
Setting table to Yes, the users should get frmExitNow message on the screen
telling them that they will be logged off in 5 minutes.

The Switchboard form checks this field every 5 minutes and launches the
message form. If they still have not logged off after another 5 minutes,
they will be automatically logged off. It will also not allow anyone else to
log into the application until Logoff is set back to No.

When I change the logoff to yes, the message "The database is closed for
updating" "Please try late†pops up and automatically closes the database.
What I would like and what should happen is the frmExitNow message to appear
first to warn the users then the after 5minute the actually Logoff message.
Can someone helps? Would the DAO version effect the results? Any assist
would be appreciated.


It has several pieces;

1. Code in the frmLogOff form (this form) OnTimer and OnLoad events, the
Timer Interval is set for 5 minutes: 300000. The same code is in my
Switchboard.

On Timer is as follows:

Private Sub Form_Timer()
Dim db As DAO.Database
Dim snp As DAO.Recordset
Dim msg As String, intLogoff As Integer

Set db = CurrentDb
Set snp = db.OpenRecordset("tblSettings", dbOpenSnapshot)
intLogoff = snp![logoff]
snp.Close
db.Close

If intLogoff = True Then
If Me.Tag = "MsgSent" Then
Application.Quit (acQuitSaveAll)
Else
Me.Tag = "MsgSent"
DoCmd.OpenForm "frmExitNow"
End If
End If

End Sub

OnLoad event as follows:

Private Sub Form_Load()
Dim db As DAO.Database
Dim snp As DAO.Recordset
Dim msg As String

Set db = CurrentDb
Set snp = db.OpenRecordset("tblSettings", dbOpenSnapshot)
If snp![logoff] Then
msg = "The database is closed for updating" & vbCrLf & vbCrLf & "Please try
later."
MsgBox msg
Application.Quit
End If
DoCmd.Hourglass False

End Sub


2. A linked table called 'tblSettings' with only one Yes/No field called
'Logoff' in the BackEnd and linked table in the FrontEnd.

3. There is the frmExitNow modal form with the message: This application
will automatically close in 5 minutes for maintenance. Please exit as soon as
possible.
You may try opening the application again in 10 minutes.

The coding as follows:

Private Sub Form_Load()
Detail.BackColor = vbYellow
Label0.ForeColor = vbRed
End Sub

Private Sub Form_Timer()
DoCmd.Beep
If Detail.BackColor = vbYellow Then
Detail.BackColor = vbRed
Label0.ForeColor = vbYellow

Else
Detail.BackColor = vbYellow
Label0.ForeColor = vbRed

End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top