Sum Times and Display Result - Access 97

  • Thread starter Thread starter Leonard Priestley
  • Start date Start date
L

Leonard Priestley

I am writing a database to enable me to record the time I spend on various
tasks. Some tasks get done in several sessions, and I would like to sum the
times in these sessions, using a TaskID autonumber field to specify the
sessions that should be included in the sum. I have a table called tblTask,
and one called tblSession that links to it using TaskID.

I have created a Select query that goes like this:

SELECT Sum(tblSession.SessionTimeTaken) AS SumOfSessionTimeTaken
FROM tblSession
WHERE (((tblSession.TaskID) = (txtTaskID).(Value)));

-- txtTaskID is a textbox bound to the field TaskID, and shows the
value of TaskID for the current record in tblTask.

I can run the query separately (from the database window) and get a result,
but I can't do the same in the form, and I can't see how to get and use the
result of the query. What I would like to get is a sum like 01:23, or even
a decimal hour, but I'm obviously way off track. I'm just pretty ignorant
of queries at present.

Help would be appreciated. Even sympathy is acceptable.

But help would be better.

Leonard Priestley
 
If this is a form in Form View (not Continuous or Datasheet), so you just
need one value at a time, try something like this:

=DSum("SessionTimeTaken", "tblSession", "TaskID = " & Nz([txtTaskID], 0))

If the results are more than 24 hours, it will wrap on the day, and you will
need to use DateDiff() to sort it out.

More information on how to work with times:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html
 
Back
Top