D
Don
I have a timer form that I need to change a parameter. This form is only on
the front-end part of the application. The forms' purpose is to close the
front end of the database if the user forgot to close it before going home.
Closing the front end or making sure everyone in not accessing records is
required to be able to update, append, delete and recreate tables on the
backend of the database. When the front ends are open the process on the back
end errors out and the update is not done.
The problem with the current timer is when the user does close the front end
not allowing the it's code to run at the time selected. What happens is when
the user opens the database the application closes. This works for any user
who understands what is going on but those who do not, think something is
wrong with the application (besides my abilities). The way the code works now
is if the date is less than today’s date and if it is after 5:10 AM then
process the code that closes the database.
What I would like is to look at the same criteria but if the time is after
say 6:15 AM then only update the date in the timer table and do not close the
database. The following is the current code:
Private Sub Form_Timer()
On Error GoTo Err_Form_Timer
If Time() > #5:10:00 AM# Then
If DLookup("LastTimerDate", "tblTimerDate") < DATE Then
CurrentDb.Execute _
"UPDATE tblTimerDate SET LastTimerDate = " & _
Format(DATE, "\#mm/dd/yyyy\#")
' Closes database and compacts and repairs database allowing
' Server to update and create needed daily reports.
DoCmd.Quit
End If
Form_Timer_Exit:
Exit Sub
Err_Form_Timer:
MsgBox Error$
Resume Form_Timer_Exit
MsgBox Err.Number & Err.Description
Resume Form_Timer_Exit
End If
End Sub
This is my attempt to modify the code to 1) perform the above if between
5:10 and 6:15 AM if not, then 2) only change the date without closing the
front end after 6:15. With my additions, nothing happens. What am I missing?
My changes in bold.
Private Sub Form_Timer()
On Error GoTo Err_Form_Timer
If Time() > #5:10:00 AM# And < #6:15 AM# Then
If DLookup("LastTimerDate", "tblTimerDate") < DATE Then
CurrentDb.Execute _
"UPDATE tblTimerDate SET LastTimerDate = " & _
Format(DATE, "\#mm/dd/yyyy\#")
' Closes database and compacts and repairs database allowing
' Server to update and create needed daily reports.
DoCmd.Quit
Else
If DLookup("LastTimerDate", "tblTimerDate") < DATE Then
CurrentDb.Execute _
"UPDATE tblTimerDate SET LastTimerDate = " & _
Format(DATE, "\#mm/dd/yyyy\#")
End If
End If
Form_Timer_Exit:
Exit Sub
Err_Form_Timer:
MsgBox Error$
Resume Form_Timer_Exit
MsgBox Err.Number & Err.Description
Resume Form_Timer_Exit
End If
End Sub
Thanks,
Dennis
the front-end part of the application. The forms' purpose is to close the
front end of the database if the user forgot to close it before going home.
Closing the front end or making sure everyone in not accessing records is
required to be able to update, append, delete and recreate tables on the
backend of the database. When the front ends are open the process on the back
end errors out and the update is not done.
The problem with the current timer is when the user does close the front end
not allowing the it's code to run at the time selected. What happens is when
the user opens the database the application closes. This works for any user
who understands what is going on but those who do not, think something is
wrong with the application (besides my abilities). The way the code works now
is if the date is less than today’s date and if it is after 5:10 AM then
process the code that closes the database.
What I would like is to look at the same criteria but if the time is after
say 6:15 AM then only update the date in the timer table and do not close the
database. The following is the current code:
Private Sub Form_Timer()
On Error GoTo Err_Form_Timer
If Time() > #5:10:00 AM# Then
If DLookup("LastTimerDate", "tblTimerDate") < DATE Then
CurrentDb.Execute _
"UPDATE tblTimerDate SET LastTimerDate = " & _
Format(DATE, "\#mm/dd/yyyy\#")
' Closes database and compacts and repairs database allowing
' Server to update and create needed daily reports.
DoCmd.Quit
End If
Form_Timer_Exit:
Exit Sub
Err_Form_Timer:
MsgBox Error$
Resume Form_Timer_Exit
MsgBox Err.Number & Err.Description
Resume Form_Timer_Exit
End If
End Sub
This is my attempt to modify the code to 1) perform the above if between
5:10 and 6:15 AM if not, then 2) only change the date without closing the
front end after 6:15. With my additions, nothing happens. What am I missing?
My changes in bold.
Private Sub Form_Timer()
On Error GoTo Err_Form_Timer
If Time() > #5:10:00 AM# And < #6:15 AM# Then
If DLookup("LastTimerDate", "tblTimerDate") < DATE Then
CurrentDb.Execute _
"UPDATE tblTimerDate SET LastTimerDate = " & _
Format(DATE, "\#mm/dd/yyyy\#")
' Closes database and compacts and repairs database allowing
' Server to update and create needed daily reports.
DoCmd.Quit
Else
If DLookup("LastTimerDate", "tblTimerDate") < DATE Then
CurrentDb.Execute _
"UPDATE tblTimerDate SET LastTimerDate = " & _
Format(DATE, "\#mm/dd/yyyy\#")
End If
End If
Form_Timer_Exit:
Exit Sub
Err_Form_Timer:
MsgBox Error$
Resume Form_Timer_Exit
MsgBox Err.Number & Err.Description
Resume Form_Timer_Exit
End If
End Sub
Thanks,
Dennis