Action at set time

SteveE

Registered User.
Local time
Today, 03:13
Joined
Dec 6, 2002
Messages
221
I wish to close my DB at a certain time at night and am using this very simple code but it only work on the exact time, can someone advise how to implement a between time I have a hidden form which opens with the DB and uses a timer event to run this code

Private Sub Form_Timer()
Me.CurrentTime.Value = Time()
If Me.BackupT = Me.CurrentTime Then
Application.Quit (acQuitSaveAll)
End If
End Sub

What I would like is to have a range of time ie 30minutes where the DB cannot be started

any advise appricated

S
 
I would just take your current backup time, add 10 minutes (or whatever you want) to it and check the current time is > start time and < end time, basically.
If it is a date datatype you can use DATEADD to add minutes.
DATEADD("n",10,StartDatetime)
 
Action at Set Time

Many thanks for the reply but I seem to have a problem with the "and" in the statement. Rather than adding time to my Backup time I just have another field Me.ReOpen pre-set to whatever time I default it to
Its the and format which causes me trouble as Access declares a syntax error ?

Private Sub Form_Timer()
Me.CurrentTime.Value = Time()

If Me.CurrentTime > Me.BackUpTime and < Me.ReOpen Then

Application.Quit (acQuitSaveAll)

End If

End Sub
 
If Me.CurrentTime > Me.BackUpTime and Me.CurrentTime < Me.ReOpen Then
 

Users who are viewing this thread

Back
Top Bottom