I have a DBGrid that displays working hours for jurors (total hours is a calculated field in the query):
on the same form is a TOTAL HOURS display. I calculate this total in the calculated field code:
So for the data above, the total hours worked is 27.
The DBGrid is large enough to hold 6 entries. Subsequently the Hours Worked label only sums those first 6 entries. So, for the example above, only the first six entries are summed and the total hours displayed is 25. If I enlarge the DBGrid to fit 10 rows, the total hours display is correct at 27.
I moved the bolded calculation to the OnShow event and it works correctly now, I was just wondering if this is normal.
Thanks for any insight!!!
Les
Code:
Date Type Time In Time Out Total Hours
1/18/2005 ORIENT 8:30 AM 4:00 PM 7.5
1/19/2005 JUROR 11:00 AM 5:30 PM 6.5
1/20/2005 JUROR 11:00 AM 2:30 PM 3.5
1/21/2005 DLYPNL 9:30 AM 1:00 PM 3.5
1/25/2005 DLYPNL 2:00 PM 4:00 PM 2.0
1/26/2005 JUROR 1:00 PM 3:00 PM 2.0
1/27/2005 DLYPNL 2:00 PM 4:00 PM 2.0
on the same form is a TOTAL HOURS display. I calculate this total in the calculated field code:
Code:
procedure TfrmJurorInformation.qryJurorHoursCalcFields(DataSet: TDataSet);
begin
with qryJurorHours do
begin
if FieldByName('TIMEOUT').AsInteger <> 0 then
FieldByName('TotalTime').Value := FloatToStr((HourSpan(IntToTime(FieldByName('TimeIn').AsInteger), IntToTime(FIeldByName('TimeOut').AsInteger))))
else
FieldByName('TotalTime').Value := '??';
[b]if FieldByName('TotalTime').value <> '??' then
dblHrsWorked := dblHrsWorked + FieldByName('TotalTime').value;[/b]
end;
end;
So for the data above, the total hours worked is 27.
The DBGrid is large enough to hold 6 entries. Subsequently the Hours Worked label only sums those first 6 entries. So, for the example above, only the first six entries are summed and the total hours displayed is 25. If I enlarge the DBGrid to fit 10 rows, the total hours display is correct at 27.
I moved the bolded calculation to the OnShow event and it works correctly now, I was just wondering if this is normal.
Thanks for any insight!!!
Les