I do have a long type. I have a hidden form name frmLogoutStatus that opens when the database is opened through the autoexec macro. When this hidden form is opened this Load event code executes. Every 10 seconds, the timer event code executes seen below. However, within the first 10 seconds I get an error indicating 'Overflow'. I dont know why.
Private Sub Form_Load()
On Error GoTo Err_Close_Jobs
Dim intISecs As Long
Dim strSelect As String
Dim var As Variant
Dim db As DAO.Database
strSelect = "Select Settings.Logoff " & vbCrLf & "From Settings In 'T:\eng\Lopez\Early Stage Order Tracking_be.accdb'"
Set db = CurrentDb
var = db.OpenRecordset(strSelect)(0)
If Nz(var, 0) = "True" Then
mdat_StartCountdownTime = Now()
End If
Form.TimerInterval = 10000
Exit_Close_Jobs:
Exit Sub
Err_Close_Jobs:
MsgBox Err.Number & "/" & Err.Description
Resume Exit_Close_Jobs
End Sub
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Private Sub Form_Timer()
On Error GoTo Err_Close_Jobs
Dim intIMins As Integer
Dim intISecs As Long
Dim strSelect As String
Dim var As Variant
Dim db As DAO.Database
strSelect = "Select Settings.Logoff " & vbCrLf & "From Settings In 'T:\eng\Lopez\Early Stage Order Tracking_be.accdb'"
Set db = CurrentDb
var = db.OpenRecordset(strSelect)(0)
If Nz(var, 0) = "True" Then
intISecs = DateDiff("s", mdat_StartCountdownTime, Now())
Debug.Print intISecs
'Display the current seconds remaining in the 'text box corner of form
If intISecs = 0 And intISecs < 11 Then
DoCmd.OpenForm "frmLogoutStatus", acNormal
Me.txtCounter.Value = "Less then 5 min"
End If
If intISecs > 179 And intISecs < 189 Then
DoCmd.OpenForm "frmLogoutStatus", acNormal
Me.txtCounter.Value = "Less than 2 min"
End If
'If the Seconds Counter (TimerCount) is now equal
'to 40 seconds then the text color changed to Red
If intISecs > 239 And intISecs < 249 Then
DoCmd.OpenForm "frmLogoutStatus", acNormal
Me.txtCounter.ForeColor = vbRed
Me.txtCounter.Value = "Less then 1 min"
End If
If intISecs > 279 And intISecs < 289 Then
DoCmd.OpenForm "frmLogoutStatus", acNormal
Me.txtCounter.ForeColor = vbRed
Me.txtCounter.Value = "Less then 20 seconds"
End If
If intISecs > 289 And intISecs < 298 Then
DoCmd.OpenForm "frmLogoutStatus", acNormal
Me.txtCounter.ForeColor = vbRed
Me.txtCounter.Value = "Less then 20 seconds"
End If
If intISecs > 300 Then
'Close the Access Program when the counter is equal to 61 seconds
DoCmd.Quit acQuitSaveAll
End If
Else
Form.TimerInterval = 0
DoCmd.Close acForm, "frmLogoutStatus"
DoCmd.OpenForm "CrisisAverted", , , , , acDialog
Exit Sub
End If
Exit_Close_Jobs:
Exit Sub
Err_Close_Jobs:
MsgBox Err.Number & "/" & Err.Description
Resume Exit_Close_Jobs
End Sub
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////