Expression to count hours for present day

C

Chantel33

I have the following expression on my form in my Total Hours field:

IIf ( [Processed Date] = Now () , Sum ( [Hours] ) , 0)

I would like for the total hours field to sum the hours entered for the
present day, but i am getting an error. Please help. I would like my total
hours to reflect hours entered and processed for the current day, each day.
 
J

John W. Vinson

I have the following expression on my form in my Total Hours field:

IIf ( [Processed Date] = Now () , Sum ( [Hours] ) , 0)

I would like for the total hours field to sum the hours entered for the
present day, but i am getting an error. Please help. I would like my total
hours to reflect hours entered and processed for the current day, each day.

Now() will basically never equal [Processed Date]. It returns the current date
AND TIME accurate to a few microseconds.

Where is this expression? What is in the [Hours] fields - hours for this date,
for various dates, or what? What's the context?

If you want to go directly to the table rather than the form you could use

=DSum("[Hours]", "[tablename]", "[Processed Date] = #" & Date() & "#")

but I'm not sure that's what you want.
 
J

John W. Vinson

I have the following expression on my form in my Total Hours field:

IIf ( [Processed Date] = Now () , Sum ( [Hours] ) , 0)

I would like for the total hours field to sum the hours entered for the
present day, but i am getting an error. Please help. I would like my total
hours to reflect hours entered and processed for the current day, each day.

Now() will basically never equal [Processed Date]. It returns the current date
AND TIME accurate to a few microseconds.

Where is this expression? What is in the [Hours] fields - hours for this date,
for various dates, or what? What's the context?

If you want to go directly to the table rather than the form you could use

=DSum("[Hours]", "[tablename]", "[Processed Date] = #" & Date() & "#")

but I'm not sure that's what you want.
 
C

Chantel33

Where is this expression? What is in the [Hours] fields - hours for this
date,
for various dates, or what? What's the context?
the expression is in the Total Hours field this is an unbound text field

nothing is in the hours field, this is where we enter the total amount of
time spent on a task. The total field was created to sum up those hours but
i only want what is done for today to show up in the total hours field on my
form.

John W. Vinson said:
I have the following expression on my form in my Total Hours field:

IIf ( [Processed Date] = Now () , Sum ( [Hours] ) , 0)

I would like for the total hours field to sum the hours entered for the
present day, but i am getting an error. Please help. I would like my total
hours to reflect hours entered and processed for the current day, each day.

Now() will basically never equal [Processed Date]. It returns the current date
AND TIME accurate to a few microseconds.

Where is this expression? What is in the [Hours] fields - hours for this date,
for various dates, or what? What's the context?

If you want to go directly to the table rather than the form you could use

=DSum("[Hours]", "[tablename]", "[Processed Date] = #" & Date() & "#")

but I'm not sure that's what you want.
 
C

Chantel33

Where is this expression? What is in the [Hours] fields - hours for this
date,
for various dates, or what? What's the context?
the expression is in the Total Hours field this is an unbound text field

nothing is in the hours field, this is where we enter the total amount of
time spent on a task. The total field was created to sum up those hours but
i only want what is done for today to show up in the total hours field on my
form.

John W. Vinson said:
I have the following expression on my form in my Total Hours field:

IIf ( [Processed Date] = Now () , Sum ( [Hours] ) , 0)

I would like for the total hours field to sum the hours entered for the
present day, but i am getting an error. Please help. I would like my total
hours to reflect hours entered and processed for the current day, each day.

Now() will basically never equal [Processed Date]. It returns the current date
AND TIME accurate to a few microseconds.

Where is this expression? What is in the [Hours] fields - hours for this date,
for various dates, or what? What's the context?

If you want to go directly to the table rather than the form you could use

=DSum("[Hours]", "[tablename]", "[Processed Date] = #" & Date() & "#")

but I'm not sure that's what you want.
 
J

John W. Vinson

Where is this expression? What is in the [Hours] fields - hours for this date,
for various dates, or what? What's the context?
the expression is in the Total Hours field this is an unbound text field

nothing is in the hours field, this is where we enter the total amount of
time spent on a task. The total field was created to sum up those hours but
i only want what is done for today to show up in the total hours field on my
form.

If only today's hours are on the form just use

=Sum([hours])

If the form displays data from several days and you want to sum only those
records that are from today, do the calculation in the Query upon which the
form is based rather than on the form, in a calculated field; and include
*another* calculated field doing the same calculation in an IIF:

IIF([datefield] = Date(), [Hours], 0)

Call this field TodayHours, and in the form footer put a textbox with a
control source
=Sum([TodayHours])
 
J

John W. Vinson

Where is this expression? What is in the [Hours] fields - hours for this date,
for various dates, or what? What's the context?
the expression is in the Total Hours field this is an unbound text field

nothing is in the hours field, this is where we enter the total amount of
time spent on a task. The total field was created to sum up those hours but
i only want what is done for today to show up in the total hours field on my
form.

If only today's hours are on the form just use

=Sum([hours])

If the form displays data from several days and you want to sum only those
records that are from today, do the calculation in the Query upon which the
form is based rather than on the form, in a calculated field; and include
*another* calculated field doing the same calculation in an IIF:

IIF([datefield] = Date(), [Hours], 0)

Call this field TodayHours, and in the form footer put a textbox with a
control source
=Sum([TodayHours])
 

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