Timer

N

NotGood@All

I have a form that has a StartDate & StopDate. I use the a "DateDiff("s",
Now, EndDate) to get the seconds but it does not update. Can I add a timer
somewhere in that line of code so it will update?

Thanks
 
K

Klatuu

You don't give much info about your situation, but you could use the form's
Timer event. If you can be a bit more specific, perhaps we can help.
 
N

NotGood@All

I'm trying to create a form that gives me a running countdown from 2/9/2015
to today. I used the DateDiff that list years, months, days... but it's
static. My thinking was that if I could get seconds to work I could apply
that to the entire form. I take it my thinking is incorrect!

Thanks
 
P

PJFry

Try this:
Set your Timer event to run at the desired interval. Then on the OnTimer
event set your control to requery. I did a quick test by creating an unbound
control and setting the Control Source to
=#2/19/2015#-Now().
Under the OnTimer event I have
Me.cntTimer.Requery

Is that what you are trying to do? Given that, there is a possibility that
this could slow things down on your form.

Give it a shot.

PJ
 
K

Klatuu

Pretty good, but two same issues.
=#2/19/2015#-Now()
I would recommend
=DateDiff("d",Date(),#2/19/2015#)

As written your expression will return 2303.63850694444

Use Now only when you are dealing with time. As you can see, the return
value may cause incorrect results depending on your logic. Also, it is
better form to use data handling functions rather than straight arithmetic
with dates. It is not a requirement, but good practice.

Also, the Requery method would not be the correct method. It should be the
ReCalc method. It is used to cause calculated controls to recalculate their
values.
 
N

NotGood@All

Thank you both for your responses. I usderstand a little better now but I'm
getting an error saying "Me" is not correct.
 
K

Klatuu

Me refers to the form the code is in. If the control is in a different form,
you have to refer to the form:

Forms!FormName!ControlName

Or if it is on a sub form of the current form:

Me.SubFormControlName.Form.ControlName

Or if your current form is the subform of the form the control is on:

Me.Parent.ControlName
 
N

NotGood@All

In the forms properties I have the following code:
=[Forms]![CountDown]![text27]![recalc].[requery], countdown is the name of
the form, text27 is the name of the text field that has the seconds. I'm
getting an error "The expression on timer you entered..... "Invalid outside
procedure"

Thanks
 
K

Klatuu

Should be:
[Forms]![CountDown]![text27].recalc

NotGood@All said:
In the forms properties I have the following code:
=[Forms]![CountDown]![text27]![recalc].[requery], countdown is the name of
the form, text27 is the name of the text field that has the seconds. I'm
getting an error "The expression on timer you entered..... "Invalid
outside
procedure"

Thanks
--
NotGood@All


Klatuu said:
Me refers to the form the code is in. If the control is in a different
form,
you have to refer to the form:

Forms!FormName!ControlName

Or if it is on a sub form of the current form:

Me.SubFormControlName.Form.ControlName

Or if your current form is the subform of the form the control is on:

Me.Parent.ControlName
 

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


Top