Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculations with fixed numbers 1

Status
Not open for further replies.

flaviooooo

Programmer
Feb 24, 2003
496
FR
Hi,

I am making a report that is based on a table full of numbers with 2 or more decimals. On the report I need to make calculations with these numbers, but they need to be fixed. If i select a number, set the properties to fixed without decimals it shows OK. But when I make a calculation, it uses the number with decimals. This way my calculation aren't correct offcourse. To clear things up:

96,8 * 519 = 50239,2
It has to be 97 * 519 = 50343

Can this be done?
 
? CLng(96.8) * CLng(519)
50343


but the coercion will ROUND the value, so if you want other coercion, you need to look up the coercion functions and determine which (if any) are appropiate to your specific requirements.



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Use the following as the control source for an unbound TextBox:

=Round([Numbers],1)

where [numbers] is the column in the table for the required numbers and 1 is the number of decimal places

Aubs
 
I've just made a table with the following figures in a column called Numbers:

1.5
2.5
3.5
4.5
5.5
6.5
7.5
8.5

and in a report did:

=CLng([number])

the result in the report looks like this:

2
2
4
4
6
6
8
8

(It should be 2,3,4,5,6,7,8,9)

From the help file:

[tt]When the fractional part is exactly 0.5, CInt and CLng always round it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2.[/tt]

Prehaps this is not the case for the version of access you have? [ I'm running Win2k, AccessXP(2002) ]

Any suggestions?

Aubs
 
Hey Aubs,

you're right. I have the same problem here :-(

Unfortunately, I can't use your Round-solution either, since Access 97 doesn't seem to recognize it

Any ideas someone?
 
I must be dreaming about this nightmare! First of all, NONE of hte coercion functions appear to be (correctly) returning the fixed value. Worse YET!!! The )(*&#$*&#@(^$@&#@$*&^(*&@#$*&#@!^*&q HELP(less) system has decided that Excel help is all I need!!!! MS ==> ms All this in addition to my ISP returning an equivalent of ~~ 1kb / SEC.



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Try this, an addition to MichaelRed's previous post:
Code:
=CLng([num] + 0.1)
This seems to do the trick and overcome the MS shortcoming.....
 
but ... it resembles ye olde "bandaid on major surgical wound" thinggy. May work for the EXACT situation, could be hazzardous to hte GENERAL soloution.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top