Hidden form

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Hidden form

Post by D Willett »

Hi
I have to create a hidden form on the display database to close the application at a certain time of the day.
I've put in the timer event of the form:

Code: Select all

Private Sub Form_Timer()

    If Time >= "16:00" Then
        
        Quit acQuitSaveAll
        
    End If

End Sub
But the database didn't close at 16:00.
Do I have to also add a timer interval to the forms properties to enable this to work?

Thanks
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hidden form

Post by HansV »

Change the line

Code: Select all

    If Time >= "16:00" Then
to

Code: Select all

    If Time >= Time(16,0,0) Then
or to

Code: Select all

    If Time >= TimeValue("16:00") Then
or to

Code: Select all

    If Time >= #4:00:00 PM#  Then
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Hidden form

Post by HansV »

And yes, you have to set the Timer Interval to a positive value. It represents milliseconds, so to check every minute, set the Timer Interval to 60000 (1 minute = 60 seconds = 60000 milliseconds); to check every 5 minutes, set it to 300000 (5 minutes = 300 seconds = 300000 milliseconds).
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Hidden form

Post by D Willett »

Cheers Hans. The timer interval sorted it.
Thanks again.
Cheers ...

Dave.