Countdown timer on form

  • Follow


I have prepared a online test application over ms access. 

Can this be done?
When the user login & starts the test, a countdown timer for 30 minutes 
starts on top of form and automatically closes the form once the time is over.

I am new to coding macros, this function is important for me. Kindly help..

thanks a lot.. 
Boss
0
Reply Utf 11/28/2007 3:30:01 PM

To answer the question of whether a time interval can be set to close a form: 
Yes, this can be done.  Look in Help for the On Timer event.  This would need 
to be set up in vba.  As far as I know there are no macros for this per se.  
Open your form in design view and select it's properties.  Go to the Event 
Tab; there is a property for both On Timer and Time Interval (measured in 
miliseconds - 1000 = 1 second, 60000 = 1 minute, 1800000 = half an hour).  
First type in your Time Interval, then click on the "..." button next to the 
On Timer line, opt to use the code builder and type in the following code, 
replacing the words FormName with the name of your form, but leaving the 
quotes there:

DoCmd.Close acForm, "FormName"

However, as far as I know, you cannot use MS Access Forms/Reports or their 
associated events (both VBA and macros) online. 

Also, while I've read about a few exceptions, almost all information I have 
seen/heard/happened upon indicate that JET, the database engine that MS 
Access uses, is not really geared for use on a web server.  If this is your 
end goal, you may want to look into SQL Server.

Hope this information helps.
Tim

"Boss" wrote:

> I have prepared a online test application over ms access. 
> 
> Can this be done?
> When the user login & starts the test, a countdown timer for 30 minutes 
> starts on top of form and automatically closes the form once the time is over.
> 
> I am new to coding macros, this function is important for me. Kindly help..
> 
> thanks a lot.. 
> Boss
0
Reply Utf 11/28/2007 4:13:02 PM

This was great.. Hats-off to you..
I was busy doing bit of coding for this but failed. U found it on teh 
property tab.

Extension to this, which is my prime aim is to display a countdown on the 
form so that the user knows how much time is left. 
Could u help me over this?
My database is online means i have shared the database on the shared drive.

Thanks a lot..
Boss 

"Tim Johnson" wrote:

> To answer the question of whether a time interval can be set to close a form: 
> Yes, this can be done.  Look in Help for the On Timer event.  This would need 
> to be set up in vba.  As far as I know there are no macros for this per se.  
> Open your form in design view and select it's properties.  Go to the Event 
> Tab; there is a property for both On Timer and Time Interval (measured in 
> miliseconds - 1000 = 1 second, 60000 = 1 minute, 1800000 = half an hour).  
> First type in your Time Interval, then click on the "..." button next to the 
> On Timer line, opt to use the code builder and type in the following code, 
> replacing the words FormName with the name of your form, but leaving the 
> quotes there:
> 
> DoCmd.Close acForm, "FormName"
> 
> However, as far as I know, you cannot use MS Access Forms/Reports or their 
> associated events (both VBA and macros) online. 
> 
> Also, while I've read about a few exceptions, almost all information I have 
> seen/heard/happened upon indicate that JET, the database engine that MS 
> Access uses, is not really geared for use on a web server.  If this is your 
> end goal, you may want to look into SQL Server.
> 
> Hope this information helps.
> Tim
> 
> "Boss" wrote:
> 
> > I have prepared a online test application over ms access. 
> > 
> > Can this be done?
> > When the user login & starts the test, a countdown timer for 30 minutes 
> > starts on top of form and automatically closes the form once the time is over.
> > 
> > I am new to coding macros, this function is important for me. Kindly help..
> > 
> > thanks a lot.. 
> > Boss
0
Reply Utf 11/28/2007 5:09:01 PM

Hi

Create a new text box on your form - call it timer
set the default value to 10 (just for now)

Set the form's timer interval to 1000

Put this code on the form's On Timer event


Private Sub Form_Timer()
If Me.Timer = 0 Then
    DoCmd.Close
    Else
    Me.Timer = Me.Timer - 1
End If
End Sub

Have a look at it then alter the code and timer interval to what you need.
You don't need to use DoCmd.Close - you can put a message box or open 
another form or whatever here in the code

good luck


-- 
Wayne
Manchester, England.



"Boss" wrote:

> This was great.. Hats-off to you..
> I was busy doing bit of coding for this but failed. U found it on teh 
> property tab.
> 
> Extension to this, which is my prime aim is to display a countdown on the 
> form so that the user knows how much time is left. 
> Could u help me over this?
> My database is online means i have shared the database on the shared drive.
> 
> Thanks a lot..
> Boss 
> 
> "Tim Johnson" wrote:
> 
> > To answer the question of whether a time interval can be set to close a form: 
> > Yes, this can be done.  Look in Help for the On Timer event.  This would need 
> > to be set up in vba.  As far as I know there are no macros for this per se.  
> > Open your form in design view and select it's properties.  Go to the Event 
> > Tab; there is a property for both On Timer and Time Interval (measured in 
> > miliseconds - 1000 = 1 second, 60000 = 1 minute, 1800000 = half an hour).  
> > First type in your Time Interval, then click on the "..." button next to the 
> > On Timer line, opt to use the code builder and type in the following code, 
> > replacing the words FormName with the name of your form, but leaving the 
> > quotes there:
> > 
> > DoCmd.Close acForm, "FormName"
> > 
> > However, as far as I know, you cannot use MS Access Forms/Reports or their 
> > associated events (both VBA and macros) online. 
> > 
> > Also, while I've read about a few exceptions, almost all information I have 
> > seen/heard/happened upon indicate that JET, the database engine that MS 
> > Access uses, is not really geared for use on a web server.  If this is your 
> > end goal, you may want to look into SQL Server.
> > 
> > Hope this information helps.
> > Tim
> > 
> > "Boss" wrote:
> > 
> > > I have prepared a online test application over ms access. 
> > > 
> > > Can this be done?
> > > When the user login & starts the test, a countdown timer for 30 minutes 
> > > starts on top of form and automatically closes the form once the time is over.
> > > 
> > > I am new to coding macros, this function is important for me. Kindly help..
> > > 
> > > thanks a lot.. 
> > > Boss
0
Reply Utf 11/28/2007 6:09:02 PM

put a label called time_left on your form and set the timer interval to 1000. 
 Then insert the following code:

Private Sub Form_Timer()
   Call tick_timer(False)
End Sub

Private Sub Form_Open(Cancel As Integer)
   Call tick_timer(True)
End Sub

Sub tick_timer(Optional reset As Boolean)
    Dim x As Variant
    Static end_time As Date
    
    If reset Then
       end_time = DateAdd("n", 30, Now())
    End If
    
    Me.Label3.Caption = end_time
    x = Int(DateDiff("s", Now(), end_time) / 60)
    x = x & ":" & Right("0" & DateDiff("s", Now(), end_time) Mod 60, 2)
    
    Me.Label1.Caption = x
End Sub

"Boss" wrote:

> This was great.. Hats-off to you..
> I was busy doing bit of coding for this but failed. U found it on teh 
> property tab.
> 
> Extension to this, which is my prime aim is to display a countdown on the 
> form so that the user knows how much time is left. 
> Could u help me over this?
> My database is online means i have shared the database on the shared drive.
> 
> Thanks a lot..
> Boss 
> 
> "Tim Johnson" wrote:
> 
> > To answer the question of whether a time interval can be set to close a form: 
> > Yes, this can be done.  Look in Help for the On Timer event.  This would need 
> > to be set up in vba.  As far as I know there are no macros for this per se.  
> > Open your form in design view and select it's properties.  Go to the Event 
> > Tab; there is a property for both On Timer and Time Interval (measured in 
> > miliseconds - 1000 = 1 second, 60000 = 1 minute, 1800000 = half an hour).  
> > First type in your Time Interval, then click on the "..." button next to the 
> > On Timer line, opt to use the code builder and type in the following code, 
> > replacing the words FormName with the name of your form, but leaving the 
> > quotes there:
> > 
> > DoCmd.Close acForm, "FormName"
> > 
> > However, as far as I know, you cannot use MS Access Forms/Reports or their 
> > associated events (both VBA and macros) online. 
> > 
> > Also, while I've read about a few exceptions, almost all information I have 
> > seen/heard/happened upon indicate that JET, the database engine that MS 
> > Access uses, is not really geared for use on a web server.  If this is your 
> > end goal, you may want to look into SQL Server.
> > 
> > Hope this information helps.
> > Tim
> > 
> > "Boss" wrote:
> > 
> > > I have prepared a online test application over ms access. 
> > > 
> > > Can this be done?
> > > When the user login & starts the test, a countdown timer for 30 minutes 
> > > starts on top of form and automatically closes the form once the time is over.
> > > 
> > > I am new to coding macros, this function is important for me. Kindly help..
> > > 
> > > thanks a lot.. 
> > > Boss
0
Reply Utf 11/28/2007 6:37:02 PM

4 Replies
2055 Views

(page loaded in 0.085 seconds)


Reply: