Counter reset

K

Kay

Hi
I have used a counter on my form that displays the total number of
record in my table. I put a label in my form and used it to show the
count. I have used the following code in the OnTimer() event:

Me!label59.Caption = DCount("*", "Current Jobs")

Has anyone any ideas how I can get the counter to reset to zero at the
start of every day or better still at 6am every morning so that the
counter only shows total records saved during that day.

Any help is much appreciated
 
F

fredg

Hi
I have used a counter on my form that displays the total number of
record in my table. I put a label in my form and used it to show the
count. I have used the following code in the OnTimer() event:

Me!label59.Caption = DCount("*", "Current Jobs")

Has anyone any ideas how I can get the counter to reset to zero at the
start of every day or better still at 6am every morning so that the
counter only shows total records saved during that day.

Any help is much appreciated

Add a new field to your table.
Name it "DateEntered" Date/Time datatype.

Include this field on your form.
You can make it not visible if you don't wish to show it.

Add an unbound text control to the form.
Name this control "TodaysCount"

Set [TodaysCount] control source to:

=DCount("*","CurrentJobs","[DateEntered] Between Date() + #06:00:00#
and (Date()+1) + #05:59:59#")

Code the Form's BeforeUpdate event:
If Me.NewRecord =True then
Me![DateEntered] = Now()
Me![TodaysCount].Requery
End If

Only today's newly entered records between 6 AM and 5:59 AM the next
morning will be in each count.
 

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

Top