Formatting the following number from this query

J

Jason M Canady

Hi, I hope that this is the correct place to post this message... I am
trying to get the result of this feild to format with only 1 decimal... I
am getting strange results when it runs and funnier results when the results
are used in a report.

For example: If C = 1.2 and T = 78 the result in CXT = 93.60001 (???!!!) a
calculator gives only the result of 93.6!

i am using the following SQL: IIf(IsNull([c]),"---",([c]*[t])) AS CxT

This allows a blank cell to be filled with three dashes should there be no
data for a given day. Any assistance you can offer would be greatly
appreciated.

TIA Jason
 
J

Jason M Canady

John,
Thank-you for your reply. It worked perfectly! I think you could read every
book ever writted about access and still have room to learn.

Thanks again,
Jason
John Viescas said:
Jason-

I bet either C or T are floating-point numbers - probably Single. Fractions
in floating point are very imprecise because the actual stored value is the
sum of negative powers of 2 (bits to the right of the "decimal" point). So,
the number that's the result of multiplying or dividing a fraction will be
very close, but not exact. To get the number to display correctly, add the
Format function:

IIf(IsNull([c]),"---", Format([c]*[t], "0.0")) AS CxT


--
John Viescas, author
"Microsoft Office Access 2003 Inside Out" (coming soon)
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Jason M Canady said:
Hi, I hope that this is the correct place to post this message... I am
trying to get the result of this feild to format with only 1 decimal... I
am getting strange results when it runs and funnier results when the results
are used in a report.

For example: If C = 1.2 and T = 78 the result in CXT = 93.60001
(???!!!)
a
calculator gives only the result of 93.6!

i am using the following SQL: IIf(IsNull([c]),"---",([c]*[t])) AS CxT

This allows a blank cell to be filled with three dashes should there be no
data for a given day. Any assistance you can offer would be greatly
appreciated.

TIA Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top