Barb:
You need to sum the times up to and including the current date:
For all vacation time taken to date by each field worker:
=DSum("[Vacation Time]", "[YourTable]", "[Workdate] <= #" & Format([Workdate]
,"yyyy-mm-dd") & "#")
For all vacation time taken within the year by each field worker:
=DSum("[Vacation Time]", "[YourTable]", "[Field Worker] = """ & [Field Worker]
& """ And [Workdate] <= #" & Format([Workdate],"yyyy-mm-dd") & "# And Year(
[Workdate] = " & Year([Workdate])
For all vacation time taken on each job by each field worker:
=DSum("[Vacation Time]", "[YourTable]", "[Field Worker] = """ & [Field Worker]
& """ And [Workdate] <= #" & Format([Workdate],"yyyy-mm-dd") & "# And [Job #]
= " & [Job #])
For all vacation time taken within the year on each job by each field worker:
=DSum("[Vacation Time]", "[YourTable]", "[Field Worker] = """ & [Field Worker]
& """ And [Workdate] <= #" & Format([Workdate],"yyyy-mm-dd") & "# And Year(
[Workdate] = " & Year([Workdate] & " And [Job #] = " & [Job #])
Formatting the date in the ISO standard date notation format of YYYY-MM-DD
ensures that it will work on any system regardless of the local regional
setting for the date format. Substitute the real table name for YourTable.
In each case the expression is entered as a single line (they'll have been
split over several lines here by your newsreader) as the control's
ControlSource property of a text box in a form or report. In a query the
expressions can be used to return a computed column, omitting the leading =
sign in this case.
Rather than storing the field worker's name in the table its better to store
a numeric FieldWorkerID which references the unique FieldWorkerID primary key
of a separate FieldWorkers table with one row per field worker. This caters
for the possibility of two having the same names (it happens more often than
you'd think). It would also be better to have separate FirstName and
LastName fields in the FieldWorkers table. On a form you can use a combo box
for the FieldWorkerID, set up as follows so that it shows the name:
ControlSource: FieldWorkerID
RowSource: SELECT FieldWorkerID, FirstName & " " & LastName FROM
FieldWorkers ORDER BY LastName, FirstName;
BoundColum: 1
ColumnCount: 2
ColumnWidths: 0cm;8cm
If your units of measurement are imperial rather than metric Access will
automatically convert the last one. The important thing is that the first
dimension is zero to hide the first column and that the second is at least as
wide as the combo box.
Ken Sheridan
Stafford, England
see below data:
Field Worker Job # Workdate Vacation Time (hours) VH TotVacTak
CAGNEY, KEVIN 90180056 9/28/2009 0 12
CAGNEY, KEVIN 90180056 9/29/2009 0 12
CAGNEY, KEVIN 90180056 9/30/2009 0 12
CAGNEY, KEVIN 90180056 10/1/2009 8 12
8
CAGNEY, KEVIN 90180056 10/2/2009 4 12
the 1st column of VH(vacation taken) shows the acutal date the vacation
taken. the second column is the DSUM- formula - text box (passed back in
based off the the dsum by man name and date within 2009) the total is
correct - BUT DO NOT LIKE that the dates prior to it taken(9/28-9/30/09) show
up as having used 12 hours of vacaction - anyway to add code in to it show a
Running Actual total -
Thanks sooo much for helping!
Barb
"Frank H" wrote:
--
Message posted via AccessMonster.com
.