473,395 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Rounding, format(), fixed, differences between Access 97 and XP.

This looks like a bug to me.

I have an expression on a report:

=Format(Sum(([Score]*[PercentOfGrade]*[PropDegree])*([ModuleCats]/[TotalCats
])),"0.00")

Score is byte
PercentOfGrade is double
PropDegree is single
ModuleCats is byte
TotalCats is integer

This is how the expression is in Access 97. Today I converted it to XP. Some
of the figures differed by 0.01 between the two versions. These are two
different front ends linked to the same back end (which is Access 97
format).

An example is a series of calculations which gives a result of 5.4250000 is
rounded up in XP to 5.43 and down in 97 to 5.42

I investigate. In the XP version the "0.00" has been changed to "Fixed". I
change it back. It won't have it. Every time I try to use "0.00" as a format
it changes it to "Fixed". I can enter either "0.00" or "Fixed" in Access 97.
Though it DOESN'T change the result.

I look at the help file which for 97 reports:

'Fixed Display at least one digit to the left and two digits to the right of
the decimal separator.'

but for XP reports (eventually!):

'Display at least one digit; follow the settings specified in Regional
Settings in Windows Control Panel for negative amounts, decimal and currency
symbols, and decimal places'

I'll experiment. I change my regional settings to 3 decimal places and
reboot. Same thing. Access XP doesn't now try to correct "0.000" as a format
to "Fixed" which is sort of what you'd expect. What I mean is it appears
initially that if you enter "0.00" as a numeric format then Access XP
recognizes that as your regional numeric format, and changes it to 'Fixed'
because it thinks that's what you really mean. Hmmph. But it doesn't seem to
be smart enough to figure it out if you actually have changed your regional
settings. So the help file is wrong. Again. Bah!

OK, I've set these two front ends to use EXACTLY the same expression:

=Format(Sum(([Score]*[PercentOfGrade]*[PropDegree])*([ModuleCats]/[TotalCats
])),"Fixed")

For a value whose true value is 5.425 Access 97 displays 5.42 and Access XP
displays 5.43 (it should be displaying 5.425 according to the help file, as
I've changed my regional settings to 3 decimal places).

There seem to be 2 things. A bug where Access XP doesn't work like the help
file says it should, and a difference in behaviour with rounding.

Any explanations?

Yours, Mike MacSween
Nov 12 '05 #1
1 15457
Mike, this isn't really surprising.

Some of the factors involved:

1. Floating point numbers can never be stored to precise values. They are
always subject to variations.

2. A97 and A2002 use completely different versions of Visual Basic. Some
differences are to be expected.

3. Your calculation is using a wild mix of data types without explicitly
typecasting.

4. There is a Round() function in A2002 which may be better than converting
the result to a string subtype with Format().

5. Access 2002 (at least) is supposed to round to the nearest even digit. It
always does this exactly for floating point numbers (as #1 above), but it
does if you convert the result to Currency.

Typecasting to Currency - i.e. CCur() - before rounding - Round() - might
give the best result. If you need a Round() for Access 97, there is one
here:
http://www.mvps.org/access/modules/mdl0054.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mike MacSween" <mi******************@btinternet.com> wrote in message
news:3f***********************@news.aaisp.net.uk.. .
This looks like a bug to me.

I have an expression on a report:

=Format(Sum(([Score]*[PercentOfGrade]*[PropDegree])*([ModuleCats]/[TotalCats ])),"0.00")

Score is byte
PercentOfGrade is double
PropDegree is single
ModuleCats is byte
TotalCats is integer

This is how the expression is in Access 97. Today I converted it to XP. Some of the figures differed by 0.01 between the two versions. These are two
different front ends linked to the same back end (which is Access 97
format).

An example is a series of calculations which gives a result of 5.4250000 is rounded up in XP to 5.43 and down in 97 to 5.42

I investigate. In the XP version the "0.00" has been changed to "Fixed". I
change it back. It won't have it. Every time I try to use "0.00" as a format it changes it to "Fixed". I can enter either "0.00" or "Fixed" in Access 97. Though it DOESN'T change the result.

I look at the help file which for 97 reports:

'Fixed Display at least one digit to the left and two digits to the right of the decimal separator.'

but for XP reports (eventually!):

'Display at least one digit; follow the settings specified in Regional
Settings in Windows Control Panel for negative amounts, decimal and currency symbols, and decimal places'

I'll experiment. I change my regional settings to 3 decimal places and
reboot. Same thing. Access XP doesn't now try to correct "0.000" as a format to "Fixed" which is sort of what you'd expect. What I mean is it appears
initially that if you enter "0.00" as a numeric format then Access XP
recognizes that as your regional numeric format, and changes it to 'Fixed'
because it thinks that's what you really mean. Hmmph. But it doesn't seem to be smart enough to figure it out if you actually have changed your regional settings. So the help file is wrong. Again. Bah!

OK, I've set these two front ends to use EXACTLY the same expression:

=Format(Sum(([Score]*[PercentOfGrade]*[PropDegree])*([ModuleCats]/[TotalCats ])),"Fixed")

For a value whose true value is 5.425 Access 97 displays 5.42 and Access XP displays 5.43 (it should be displaying 5.425 according to the help file, as I've changed my regional settings to 3 decimal places).

There seem to be 2 things. A bug where Access XP doesn't work like the help file says it should, and a difference in behaviour with rounding.

Any explanations?

Yours, Mike MacSween

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Raoul Watson | last post by:
By any chance, anyone got a rounding routine that does a work around the VB "round" bug? I still find it amazing that a company as large as Microsoft would put out a math package that is so...
3
by: Dalan | last post by:
Is there any code available to address currency rounding problems in Access 97? Apparently, selecting currency type table fields does not resolve the problem. For instance, in my form I have a...
6
by: DaveK | last post by:
I am upgrading an MS Access 97 application which uses the format function to round decimal numbers to two places e.g. format(dblValue, "standard") Having done an initial study of this...
4
by: sql guy123 | last post by:
HI, I'm pretty new to MS SQL, My problem is setting .... =Format$(Date(),"mm" & "/1/" & "YYYY") (Which is from my MS ACCESS database)
15
by: Br | last post by:
Cint(3/2) = 2 (rounded up, I would have thought the answer would be 1) Cint(5/2) = 2 (rounded down) The Access help says Cint() rounds to the nearest even number, but why?? Do I need to...
5
by: Jason | last post by:
I am having a rounding problem in a value i am trying to display in VB.NET. If I have the following code: Dim x As Single = 2726.795 Dim y As Single = Math.Round(2726.795, 2) Dim s as String =...
6
by: shaqattack1992-newsgroups | last post by:
Hello Everyone, I'm using the following on a form in my database: =(-Int(-Sum((IIf(=Yes,((*)+()), (((*)+)*1.06))*100))))/100 In this case, I want to calculate a total for an order. If...
3
by: gabo22003 | last post by:
Hello, I've inherited a tax report where all of the financial numbers are currency.This is a detailed report that lists amount, tax and total for that day ( total is listed in the database). The...
206
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.