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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Calculations within a form 1

Status
Not open for further replies.

JoanieB

Programmer
Apr 17, 2001
57
US
I have tried doing this calculation specifying the fields in the table and also tried the using textbox values. The calculation is just incorrect. Here's an example: there are only 4 decimal places in the two fields I am subtracting. The numbers are 38002.6167 minus 38002.617. There are no more decimal places that are not being showed: these are the numbers I am working with. When I subtract them in a textbox I get the result -.0002999999...etc. These numbers subtracted equal -.0003 - I've tried it on paper and on the calculator. WHY is Access giving me these extraneous decimals??

 
Sorry - the number it gives me is -2.9999...E-04.
 
Hi
I don't use access (or excel for that matter!!) but this sort of thing was a common problem with xl7 (95) when doing simple calculations you get silly results.

The workaround there might just work on an Access form. Simply perform your calculation inside the 'Round function.

For Example (very loosely)
Me.TextBox1.Value = Round(Me.TextBox2.Value - Me.TextBox3.Value, 4)


;-)
If a man says something and there are no women there to hear him, is he still wrong?
 
I am working with Access 97 and there is no round function. There is some crazy fraction of the number here, because when I manually set variables in my code to the numbers I want to subtract, it gives me a result of -2.99...E-04 {this tells me something about the fact that it's a fractional thing...E-04...but I don't know what to do about it}.
 
It's a number conversion error - decimal to binary and back. E-04 means that it's a tiny, tiny fraction of a number that can't be represented normally 'cos there would be too many digits after the dp
Try this - based on Loomah's idea:
Me.TextBox1.Value = Format((Me.TextBox2.Value - Me.TextBox3.Value),"0.0000")

For some reason (I'm no mathematician so I don't know), 3's tend to cause this more often than anything else
[poke]


HTH
~Geoff~
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top