Option Compare Database Option Explicit Const timeToRun As Date = #11:17:00 AM# Const DelayFromLastActivity As Long = 1 'minutes of delay Public TheInterval As Long Public db As Database Public rs As Recordset Dim SkipMessage As Boolean Private Sub Form_Activate() If DateDiff("s", Time(), timeToRun) < DelayFromLastActivity Then TheInterval = DelayFromLastActivity * 60 * 1000 Else TheInterval = DateDiff("s", Time(), timeToRun) * 1000 End If Me.TimerInterval = TheInterval End Sub Private Sub Form_Current() 'this should only fireon opening because this form is unbound 'MsgBox "Current Event fired" 'MsgBox GetLocalTimeFromGMT(timeToRun) 'MsgBox ConvertLocalToGMT(timeToRun) If DateDiff("s", Time(), timeToRun) < DelayFromLastActivity Then TheInterval = DelayFromLastActivity * 60 * 1000 Else TheInterval = DateDiff("s", Time(), timeToRun) * 1000 End If Me.TimerInterval = TheInterval End Sub Private Sub Form_Timer() Set db = CurrentDb Set rs = db.OpenRecordset("select * from tblTimes where 1=2;", dbOpenDynaset, dbSeeChanges) With rs .AddNew !thedatetime = Now() !theuser = ReturnUserName !thecomputer = ReturnComputerName .Update Me.txtTimer.Value = Now() Me.txtTimer.Requery End With rs.Close Set rs = Nothing db.Close Set db = Nothing SkipMessage = True Application.Quit acQuitSaveAll SkipMessage = True End Sub Private Sub Form_Unload(Cancel As Integer) Dim response As Integer If SkipMessage = False Then response = MsgBox("Did you really intend to quit The Program? Yes to Quit, no to remain in The Program", vbYesNo + vbCritical, "Quit?") If response = vbNo Then Cancel = True End If End If End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
An Experts Exchange subscription includes unlimited access to online courses.Get Started
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE