dbTalk Databases Forums  

Prevent Rounding of Double in Report

comp.databases.ms-access comp.databases.ms-access


Discuss Prevent Rounding of Double in Report in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gilgamesh
 
Posts: n/a

Default Prevent Rounding of Double in Report - 06-16-2010 , 11:17 AM






Hi,
I have a field in a report. I've specified that 3 digits be
displayed. The underlying column in the select that the report is
based on is of type double. How do I prevent the report rounding the
answer? If the value in the column is 3.0001 or 3.0009 I want the
report to display 3.000, but I cannot find a way to prevent the report
displaying 3.001 in the second case.
If anybody can tell me what to do, I'd be very grateful. Looking at
"Rounding" in Access help or in the Access books I have does not help.

Thanks,

Mike

Reply With Quote
  #2  
Old   
James A. Fortune
 
Posts: n/a

Default Re: Prevent Rounding of Double in Report - 06-16-2010 , 11:45 AM






On Jun 16, 12:17*pm, Gilgamesh <michaelsfl... (AT) gmail (DOT) com> wrote:
Quote:
Hi,
I have a field in a report. *I've specified that 3 digits be
displayed. *The underlying column in the select that the report is
based on is of type double. *How do I prevent the report rounding the
answer? * If the value in the column is 3.0001 or 3.0009 I want the
report to display 3.000, but I cannot find a way to prevent the report
displaying 3.001 in the second case.
If anybody can tell me what to do, I'd be very grateful. * Looking at
"Rounding" in Access help or in the Access books I have does not help.

Thanks,

Mike
You want to "chop" rather than round. Try (air code):

=Int([MyField] * 1000) / 1000

as the control's ControlSource to get an output of 3 when MyField is
3.0001 or 3.0009. That expression should chop/lop/crop any decimal
places after the third decimal place. Then use the control's Format
property to force the display to three decimal places. Maybe also use
Nz([MyField], 0) instead of [MyField] in the expression if MyField is
allowed to have Null values so that you don't get something like
#Error showing up on your report.

James A. Fortune
CDMAPoster (AT) FortuneJames (DOT) com

Reply With Quote
  #3  
Old   
David W. Fenton
 
Posts: n/a

Default Re: Prevent Rounding of Double in Report - 06-16-2010 , 03:16 PM



Gilgamesh <michaelsflynn (AT) gmail (DOT) com> wrote in
news:965b8426-ff21-49f3-9e9a-1f10cffa2240 (AT) 40g2000pry (DOT) googlegroups.com
:

Quote:
I have a field in a report. I've specified that 3 digits be
displayed. The underlying column in the select that the report is
based on is of type double. How do I prevent the report rounding
the answer? If the value in the column is 3.0001 or 3.0009 I
want the report to display 3.000, but I cannot find a way to
prevent the report displaying 3.001 in the second case.
If anybody can tell me what to do, I'd be very grateful. Looking
at "Rounding" in Access help or in the Access books I have does
not help.
You don't want to round, you want to truncate the value. It's a
little tricky to do that -- you'll need the non-integer part and
then use Left(3) on it. This won't work if you want the field to be
editable, though.

Access formats automatically round, and I don't think there's any
way around that, unfortunately.

It sounds to me that you're asking for the display to be inaccurate.
That is, if the stored value is 3.0009 and you display 3.000, that's
not accurate. Perhaps what you really want to do is truncate the
stored value, so that if the number is 3.0009, you want to store
3.000. That would take care of the format and rounding issues, but
it may be unsatisfactory.

But my view of it is that if it's unsatisfactory for storage, then
it's also unsatisfactory for display, as it's displaying what is, in
fact, in accurate data.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.