473,320 Members | 2,122 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,320 software developers and data experts.

Query - incorrect output when usingthe INT function

19
Hi, I have a field in a query, as follows -
SharesToPurchase: [TotalCash] / [Forms]![frm_EnterPurchaseDetails]![txtEnterPurchasePrice]

where [TotalCash = 272.58, and [txtEnterPurchasePrice] = 6.49. Dividing [TotalCash] by [txtEnterPurchasePrice] should come to exactly 42.

This is the only case in my data set where the result works out to a whole number - the rest have fractions. They should all be whole numbers. The problem I'm having is, when I apply the INT function to the above formula, the result of the formula using the figures above is now 41, not 42?! The rest are fine. Please help!
Oct 19 '06 #1

✓ answered by NeoPa

Access 2K has a Round() function.
More to the point, non-integer arithmetic will nearly always result in a value which is very close, but not equal to, the correct integral value.

Hence, in this case, because the answer is actually an exact integer, the possibility is open for a rounding error.

If you use the Round() function instead, you will still have exactly the same arithmetic, but the problem should not manifest itself due to the nature of rounding as opposed to truncating.

4 1622
Tanis
143 100+
Try Round instead of Int
Oct 19 '06 #2
birchw
19
Sorry, I forgot to mention that this is Access 2000, and there is no round function. All I need to do is remove the fractional part, but not round it. Thanks.
Oct 19 '06 #3
NeoPa
32,556 Expert Mod 16PB
Access 2K has a Round() function.
More to the point, non-integer arithmetic will nearly always result in a value which is very close, but not equal to, the correct integral value.

Hence, in this case, because the answer is actually an exact integer, the possibility is open for a rounding error.

If you use the Round() function instead, you will still have exactly the same arithmetic, but the problem should not manifest itself due to the nature of rounding as opposed to truncating.
Oct 19 '06 #4
birchw
19
Thanks. That worked. I didn't realise there was a Round function as it wasn't listed in the functions list within the Expression Builder.
Oct 19 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
22
by: Robert Brown | last post by:
suppose I have the following table: CREATE TABLE (int level, color varchar, length int, width int, height int) It has the following rows 1, "RED", 8, 10, 12 2, NULL, NULL, NULL, 20...
5
by: Hennie de Nooijer | last post by:
Hi, This is a diffcult issue to explain. I hope to make my problem clear to you. SITUATION I'm building A SLA Query for a customer. This customer has an awkward way to determine the SLA results...
4
by: No Spam | last post by:
Dear Access 2000 users, I have a crosstab query that puts together certain information perfectly. It has a criteria that is based on a form that limits how many columns are returned based on...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
1
by: Crash | last post by:
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that...
3
by: veaux | last post by:
I have a table that looks like below: Name, Address, Favorite Pet Bill Smith, 123 Smith St, Dogs Bill Smith, 123 Smith St, Cats The "Dogs" and "Cats" are actually in a lookup table, but have...
2
by: Flic | last post by:
Hi, I have a basic db that I access with MySQL query browser. Everything seems fine to me but I am using this db as part of a php shopping basket and when I try to add an item I get: Notice:...
13
by: Karl Groves | last post by:
I'm missing something very obvious, but it is getting late and I've stared at it too long. TIA for responses I am writing a basic function (listed at the bottom of this post) that returns...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.