I suspect that what you are running into now has to do with the way Access
handles dates and times. They are stored as numbers where the whole part of
the number is the day and the decimal portion is the time of day. You are
doing integer division (\) instead of (/). 12 hours would be half a day or
0.5. I suspect you are getting caught in a rounding problem where this is
rounding to zero. If Access does the rounding it will usually round .5 to
the nearest even number, in this case zero.
Where the problem comes in is that elapsed times are NOT times. A time is a
certain point during the day, such as 13:00 (or 1:00 pm in 12 hour format).
I would recommend, if you need hours and minutes, that you do all of your
calculations in minutes then change them back to hours and minutes when you
are done. The elapsed time in minutes will be an integer value, not a
date/time value.
--
Wayne Morgan
Microsoft Access MVP
Henro said:
I understand the intention of the code and it's a good idea but now, as soon
as [Totale Werkdag] <=13:00 I get the #error again. If i work more than
thirteen hours per day things work out fine. I hope you understand I don't
intend to work that much
Maybe I should have told you that the fields
[Totale Werkdag] en [TotaalDEAL] are DATE/Time fields with hours put in with
the Short Time notation. Is that what is causing the havoc? Suggestions?
Totale werkdag: (NZ([Eind dag])-NZ([Start Dag]))+(NZ([Avond Eind])-NZ([Avond
Start]))-NZ([Lunch])-NZ([Aftrekbaar])
TotaalDEAL:
NZ([InstBSItijd])+NZ([Overige])+NZ([InstONtijd])+NZ([InstONEtijd])+NZ([SolBS
Itijd])+NZ([SolONtijd])+NZ([SolONEtijd])+NZ([ProjectDEAL])+NZ([Advies
Sales
Telefonisch Consult])+NZ([Urenregistratie]![ReistijdDEALGerelateerd])
These are all hours and I need the percentage TotaalDEAL in [Totale Werkdag]
TIA Henro
Wayne Morgan said:
prcDeal: IIf([Totale werkdag]=0, 0, [TotaalDEAL]\[Totale werkdag])
--
Wayne Morgan
Microsoft Access MVP
I do in a query an calculation on 2 fields:
prcDEAL: = [TotaalDEAL]\[Totale werkdag]
The latter sometimes can be zero. In this case I get an #Error. How
can
I
convert this #Error to zero so I can do calculations on this field? I
tried
NZ and IIF but they don't seem to work (so I suppose #Error is not a Null
value?)
Any ideas?
TIA Henro