Timer

  • Thread starter Thread starter NotGood@All
  • Start date Start date
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
 
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.
 
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
 
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
 
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.
 
Thank you both for your responses. I usderstand a little better now but I'm
getting an error saying "Me" is not correct.
 
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
 
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
 
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
 
Back
Top