Hi Ron
So you are currently storing the time in a date/time field, right? And your
two fields are named "Date" and "Time"?
My first advice (which is not really related to the immediate question) is
to rename these two fields. They could be "DateWorked" and "TimeWorked"or
something like that. The reason is that "Date" and "Time" are reserved
words (they are names of VB functions) and if you continue to use them then
in the future it will cause confusion or even failure of your application.
Next, as I said, storing a time duration in a date/time field is a misuse of
that data type. However, it *can* work, provided you understand what you
are doing. This course of action may have certain advantages, such at
automatic formatting and ease of data entry.
The data/time field is actually just a double-precision floating point
number, where the whole number part is the number of days since (or before
if it's negative) 30 Dec 1899. (Don't ask me why that day was chosen!) The
decimal part of the number is the fraction of a day that has elapsed since
midnight on the given date.
So:
0.25 = 6am on 30 Dec 1899 6am (one quarter of a day after midnight)
1.5 = noon on 31 Dec 1899
39581.75 = 6pm today (13 May 2008)
Now, IF you choose a date format that doesn't include and day, month or year
components and IF none of your time intervals is as great as 24 hours, then
you CAN use a date/time field to store the time interval.
This means that you can enter 1:30:00 and have it interpreted as 1.5 hours..
Furthermore, 1:30:00 + 2:25:00 = 3:55:00.
However, the problem comes when you have:
15:00:00 + 10:00:00
This does not give the expected 25:00:00, or even 1-01:00:00, but instead
you get:
31 Dec 1899 01:00:00
or, if you are using a format such as hh:nn:ss you just get 01:00:00.
So, with all those caveats in mind, you could set the controlsource of your
unbound textbox to:
=DSum( "TimeWorked", "YourTable", "IDNumber='" & [IDNumber] &
"' and DateWorked=" & Format([DateWorked], "\#yyyy-mm-dd\#")
Note the single quotes on either side of [IDNumber]. These should be
removed if IDNumber is a numeric field, not text as you stated in your first
post.
It's unfortunate that Access does not have a data type that is specifically
designed for storing time intervals.
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
On May 12, 6:14 pm, "Graham Mandeno" <
[email protected]>
wrote:
[snip!]
Hello Graham
Just so we're on the same page here, the time that will be entered
into the "Time" field is a total amount of time it took them to
complete the assignment. In other words the job took them one hour and
thirty minutes. What I am hearing you say is that I cannot have them
enter 01:00 in the field. Here's what I wanting if my thick skull will
allow it.
ID Number Date
Time Unbound Field
First entry 445 05/12/2008
01:00 01:00
2nd entry 445 05/12/2008
03:00 04:00
3rd entry 445 05/12/2008
01:30 05:30
4th entry(new day) 445 05/13/2008
02:00 02:00
5th entry 445 05/13/2008
01:00 03:00
How I need to need to record the time is 1.0, 3.0, 1.5, etc. and store
the times in a number field, Right? Is it possible to write an
expression in the unbound field to update it? I am using a command
button on the form to go to "a new record" for the next entry?
Thanks for the patience
Ron