Countdown timer on form

B

Boss

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
 
T

Tim Johnson

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
 
B

Boss

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
 
W

Wayne-I-M

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
 
L

Lance

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

countdown timer 2
Form Timer 2
Countdown Timer on Form 5
Countdown timer 2
hh:mm:ss on a timer 2
Countdown Timer in ppt 2
CountDown with format 00:00:00 in access 4
Time Countdown 6

Top