D
DocBrown
I have the following query (stripped down to highlight the error):
SELECT Volunteers.VolunteerID, Volunteers.CommitHours,
Int(CSng(Sum([timeout]-[timein])*24)) & ":" &
Format(Int(CSng(Sum([timeout]-[timein])*1440)) Mod 60,"00") AS TotalHrs,
IIf(Not IsNull([CommitHours]),IIf([TotalHrs]>=(CStr([CommitHours]) &
":00"),True,False),null) AS Completed
FROM Volunteers LEFT JOIN VolunteerLog ON Volunteers.VolunteerID =
VolunteerLog.VolunteerID
GROUP BY Volunteers.VolunteerID, Volunteers.CommitHours;
The Volunteers table contains all the data for a particular person
(including the [CommitHours] field). the VolunteerLog table is a timesheet
where
the volunteer logs in and out ([TimeOut] and [TimeIn]) and the two tables
are related via the VolunteerID.
The "As TotalHrs" expression sums up all the time the volunteer has worked.
(I stipulate that they will never work over midnight.) Now, it's possible
that there is no entry in the [CommitHours] field AND that there might not
be any logged hours.
The problem is that where there are no logged hours, the datasheet view
displays #Error. How do I code this so either the field is blank or 0 (or
"00:00")? Also the Completed field is also displaying the #Error. The 'Not
IsNull([CommitHours]... handles that part but I've not been able to handle
the no logged hours error. I've tried some combinations of IsError() or NZ()
but haven't succeeded.
Any suggestions?
Thanks,
John
SELECT Volunteers.VolunteerID, Volunteers.CommitHours,
Int(CSng(Sum([timeout]-[timein])*24)) & ":" &
Format(Int(CSng(Sum([timeout]-[timein])*1440)) Mod 60,"00") AS TotalHrs,
IIf(Not IsNull([CommitHours]),IIf([TotalHrs]>=(CStr([CommitHours]) &
":00"),True,False),null) AS Completed
FROM Volunteers LEFT JOIN VolunteerLog ON Volunteers.VolunteerID =
VolunteerLog.VolunteerID
GROUP BY Volunteers.VolunteerID, Volunteers.CommitHours;
The Volunteers table contains all the data for a particular person
(including the [CommitHours] field). the VolunteerLog table is a timesheet
where
the volunteer logs in and out ([TimeOut] and [TimeIn]) and the two tables
are related via the VolunteerID.
The "As TotalHrs" expression sums up all the time the volunteer has worked.
(I stipulate that they will never work over midnight.) Now, it's possible
that there is no entry in the [CommitHours] field AND that there might not
be any logged hours.
The problem is that where there are no logged hours, the datasheet view
displays #Error. How do I code this so either the field is blank or 0 (or
"00:00")? Also the Completed field is also displaying the #Error. The 'Not
IsNull([CommitHours]... handles that part but I've not been able to handle
the no logged hours error. I've tried some combinations of IsError() or NZ()
but haven't succeeded.
Any suggestions?
Thanks,
John