How do display a countdown timer

J

jagnval

I am creating an auction database to help in the removal of unused items at
my work place and need to display a countdown timer of how much longer items
are open for bidding, any help will be greatly appreciated.
 
T

Tom van Stiphout

On Tue, 10 Mar 2009 08:32:17 -0700, jagnval

I am assuming you already have a field in your Items table to record
the EndOfBidding date/time.
In your form (I am assuming bound to the Items table) create a new
label, say lblCountdown.
Set the form's TimerInterval to for example 5000 so the timer ticks
every 5 seconds.
In the Form_Timer event write:
Me.lblCountdown.Caption = datediff("s", Now, Me.EndOfBidding)

This would give you the number of seconds until EoB. Use the Format
function if you want to format this value differently.

-Tom.
Microsoft Access MVP
 
J

jagnval

Tom,

First off thank you for your help. I have the run the DateDiff and I have
the seconds until the ending bid date on a timer interval of 1 second, but I
can't get it reformatted into the format I want of hh:mm:ss. may be even
days, I would like for it to be like a countdown clock when the seconds
start at 60 and countdown to 0 and that would take off 1 min and so on.
 
T

Tom van Stiphout

On Wed, 11 Mar 2009 06:47:01 -0700, jagnval

Do some simple math. First calculate the hours by doing an integer
division:
dim secs as long
secs = datediff(...)
dim h as integer
h = secs \ (60*60)

Get the remainder:
secs = secs - h * 60*60

Repeat this for minutes and seconds. Format as a string.

-Tom.
Microsoft Access MVP
 
T

Tom van Stiphout

On Wed, 11 Mar 2009 06:47:01 -0700, jagnval

The basic idea is that if you divide by 60*60 you get the number of
hours. Use the \ to get an integer division:
secs = datediff(...)
dim h as integer
h = secs\(60*60)

Then subtract those seconds from secs and you are left with the
remainder:
dim remainder as long
remainder = secs - (h*60*60)

Then do the same for minutes, etc.

-Tom.
Microsoft Access MVP
 

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 1
Countdown timer 1
Is there such a thing as a countdown timer? 15
Countdown Timer 1
Countdown Timer on Form 5
timer 4
Time countdown 4
display countdown timer in Excel 2

Top