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

calculated field not calculating decimals correctly

fnwtech
48
I have a report card that calculates 6 fields and then takes the sum of these fields and substitutes it for a number grade. For example 5+4+3+4+5+5 = 26 The 26 is looked up in a table and the field displays 89. It seems to work fine when the scores are even numbers. However, teachers asked to be able to use whole and half grades between 0 and 5 (1, 1.5, 2, 2.5, etc). When the use a decimal, it often gives them a lower score - not sure if it isn't adding the decimals?
An example:
4+4+4.5+3.5+4.5+5 = 25.5
in the lookup, that should generate a score of 88. However, instead it is taking the value for a score of 26 - giving the student an 89.

It doesn't always round up though, sometimes it appears to round down and give a lower score than it should.

Now the lookup table has all of the values and their equivalents. Here is a sample:
26.5 90
27 91
27.5 93
28 94
28.5 96
29 97
29.5 99
30 100


Here is the formula used:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Percent_GotFocus()
  2. Percent = [Understanding] + [Quality] + [Communication] + _
  3.              [Completion] + [Preparation] + [Participation]
  4.  
  5. Percent = Nz(DLookup("CalcPercent", "Percent_Comp_Table", "OrigPercent = " & Percent), 0)
  6. End Sub
In the table,
fieldtype - Number
Field size - Long integer (I know, not needed, but this is what it was set to)
Format - not set (though I tried general)
Decimal - Auto

Any thoughts on this would be appreciated!
smg
Mar 26 '10 #1

✓ answered by NeoPa

Integer & Long (integer) types are not good for handling decimal values.

Were the fields set up before the request to extend the possible values to fractional decimals?

5 5813
NeoPa
32,556 Expert Mod 16PB
Integer & Long (integer) types are not good for handling decimal values.

Were the fields set up before the request to extend the possible values to fractional decimals?
Mar 26 '10 #2
fnwtech
48
Yes. And then once I made them decimals, I removed the field from the form and put it back in, not sure if I had to or not.
Mar 29 '10 #3
fnwtech
48
I think I may have just figured out what was wrong. In the table, for the field where the calculation takes place, I had not set it to use decimals... so when adding the fields, I think it was dropping the decimal. Once I changed that, it seems to work.
Mar 29 '10 #4
fnwtech
48
Yup, that was my issue. Once I made that field a Decimal field with a precision point of 5, it worked correctly.
Mar 29 '10 #5
NeoPa
32,556 Expert Mod 16PB
Indeed. That was my guess as to the problem.

I'm glad you managed to sort it out :)
Mar 29 '10 #6

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

Similar topics

0
by: Henry | last post by:
Hi Is there any good ideas how to update form vb code always after some values are changed / added by vb (not user). I have some code behind subforms vb and there are calculations behind...
14
by: Allen Browne | last post by:
Subform is based on a single-table query that contains a calculated field: Amount: Round(CCur(Nz(*,0)),2) Continuous subform displays this field in a text box named Amount. As user enters new...
1
by: Yuki | last post by:
Thanks for taking the time to look at my problem. I keep getting a #Name error from a calculated field on a form. It is a text box field unbound. The calculation is very very simple yet I still...
1
by: Norbert Lieckfeldt | last post by:
MS Access 2002 here. I am just trying to set up a simple database for a friend who's an optician. Basically, all clients with address details, date of last eyetest and a drop-down combo box to...
2
by: hhathome | last post by:
In my report I have a calculated DateDiff Field, I also have a calculated count field. I'm trying to get a total of the DateDiff field and dividing it by the count field and I'm having problems --...
3
by: paulquinlan100 | last post by:
Hi I have a couple of calculated fields in a report, i've set the Decimal Places property to 0 and the format to General Number, however when previewing the report it still comes up with a...
3
by: kelley.l.turner | last post by:
Hi all, I am very new to MS Access so please bear with me! I have created a simple calculated field in my data entry form, yet when I view my data table or try to generate a report based on...
5
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public...
2
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by...
9
by: JCCDEVEL | last post by:
Hi All, I'm trying to do the following: 1) ON a php page, calculate fees based upon user entires. I'm calculating it in a javascript function and that is working well. However, I need to take...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.