p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: Problems With Proper Calculation


Message #1 by brose@u... on Tue, 26 Jun 2001 15:15:23
I am created some reports in Access and have ran into a problem. In one 

query I do I subtract two dates to get the time in between and multiply by 

24 to get the value in hours. I then want to check if that value is <= a 

Parameter value. So the Field looks something like this in the query:



SLA: IIf ([numTurn] <= [TimeNeeded], "Yes", "No")



Where numTurn is the calculated time of hours and TimeNeeded is the 

paramter that is entered by the user. For some reason the field is giving 

yes for all my records though. There are only 2 records that fit the query 

but one of them should not be coming up as a yes. The records read like 

this (TimeNeeded is entered as 4):



numTurn      SLA



143.79       Yes

   .07       Yes



Is there some kind of formatting I am missing that would mess this up or 

am I doing the expression wrong? Please help.
Message #2 by Brian Skelton <brian.skelton@b...> on Tue, 26 Jun 2001 15:35:58 +0100
It sounds like a data type conversion problem. See if this works:



IIf (csng([numTurn]) <= csng([TimeNeeded]), "Yes", "No")



which will explicity change the data type.



-BDS





-----Original Message-----

From:	brose@u... [SMTP:brose@u...]

Sent:	26 June 2001 16:15

To:	Access

Subject:	[access] Problems With Proper Calculation



I am created some reports in Access and have ran into a problem. In one 

query I do I subtract two dates to get the time in between and multiply by 

24 to get the value in hours. I then want to check if that value is <= a 

Parameter value. So the Field looks something like this in the query:



SLA: IIf ([numTurn] <= [TimeNeeded], "Yes", "No")



Where numTurn is the calculated time of hours and TimeNeeded is the 

paramter that is entered by the user. For some reason the field is giving 

yes for all my records though. There are only 2 records that fit the query 

but one of them should not be coming up as a yes. The records read like 

this (TimeNeeded is entered as 4):



numTurn      SLA



143.79       Yes

   .07       Yes



Is there some kind of formatting I am missing that would mess this up or 

am I doing the expression wrong? Please help.





Message #3 by "Darron Michael" <darron.michael@h...> on Tue, 26 Jun 2001 17:02:53
Are you using the Datediff function to subtract your dates?  If so, change 

your unit to Hours and you won't have to multiply by 24.



8^)



Darron

  Return to Index