473,699 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to calculate a Sum

I have a table with 5 fields into which the user will enter numbers,
which must add up to 100%. Say the fields are Toyotas, Missans, Mazdas,
Hondas and Other. I am having trouble writing a query using Sum which
will add these together and place the result in another field called
"total" which I will then place on a form so the user can check it
contains value 100 for each record. Any help appreciated, thanks.

Nov 13 '05 #1
7 1820
If your fields are called Toyota, Nissan etc

Use an unbound field called Total

In its record source write

=Toyota+Nissan+ Mazda+Honda+Oth er

then as you update the fields Honda, Toyota etc the total will change
showing the current sum.

You could use a VB procedure to do the same which would allow you to
test to see if the answer is less than a hundred or more than a hundred
and pop up a message box with an appropriate warning.

Nov 13 '05 #2
In article <11************ **********@g47g 2000cwa.googleg roups.com>,
ge***@sunny-side.ws opined thusly:


If your fields are called Toyota, Nissan etc

Use an unbound field called Total

In its record source write

=Toyota+Nissan +Mazda+Honda+Ot her


Sorry, I'm not that great at this yet...where do I create this? I have
succeeded in creating an unbound text frame in the form design view but I
can't see where it's "record source" is. I did succeed in getting it to echo
the value from one of the fields but when I used the expression builder to
sum them, it appended the digits instead

ie. 10, 30, 20, 5, 35 became 103020535 instead of 100.

thanks.

Nov 13 '05 #3
Are these car names the columns in a database table
or just text boxes on a form?

Nov 13 '05 #4
In article <11************ **********@g43g 2000cwa.googleg roups.com>,
th***********@g mail.com opined thusly:


Are these car names the columns in a database table
or just text boxes on a form?


They are each fields in a table. I worked my way through the Access Help
info on summing, and followed the instructions no problem to create the
unbound text box and then fill it with the expression:

=[toyota]+[mazda]+[nissan]+[honda]+[other]

but still it appends the percentages into a 10 digit integer instead of
adding them together!

Nov 13 '05 #5
What are the data types of those columns?

Nov 13 '05 #6
Assuming you have 5 fields on a form, you should be able to force a constant
sum of 100% across the fields, making user verification unnecessary.

For example, start with 20% in each of the 5 fields. When one of the fields
changes value, distribute 100 - [sum of modified fields] evenly across the
remaining unmodified fields. So if the user changes the Toyota field to 30%,
mark the Toyota field modified and distribute (100-30)/4 to each of the 4
remaining unmodified fields. And if the user then changes the Honda field to
25%, distribute (100-55)/3 to each of the 3 remaining unmodified fields.
Etc.

I suppose you will need some global variables (maybe an array?) to keep
track of which fields have been modified/marked; and you will probably need
a Reset button to reset the fields to the default 20% and unmark all fields,
if the user wants to start over; and you probably want to round to 2
decimals to force the math to be exactly right.

Ok, maybe the code gets a little complicated. Should be possible, however.

"richard" <no****@myplace .net> wrote in message
news:xJ******** **********@news-server.bigpond. net.au...
I have a table with 5 fields into which the user will enter numbers,
which must add up to 100%. Say the fields are Toyotas, Missans, Mazdas,
Hondas and Other. I am having trouble writing a query using Sum which
will add these together and place the result in another field called
"total" which I will then place on a form so the user can check it
contains value 100 for each record. Any help appreciated, thanks.

Nov 13 '05 #7
Maybe my idea is not so workable, after all. I'm concerned about the
possibility of causing an infinite loop which might happen if a user change
to one form field triggers code in another form field which in turn
retriggers the code in the original field, etc. Ugh.

"Mondrogan" <mo*******@comc ast.net> wrote in message
news:qb******** ************@co mcast.com...
Assuming you have 5 fields on a form, you should be able to force a
constant sum of 100% across the fields, making user verification
unnecessary.

For example, start with 20% in each of the 5 fields. When one of the
fields changes value, distribute 100 - [sum of modified fields] evenly
across the remaining unmodified fields. So if the user changes the Toyota
field to 30%, mark the Toyota field modified and distribute (100-30)/4 to
each of the 4 remaining unmodified fields. And if the user then changes
the Honda field to 25%, distribute (100-55)/3 to each of the 3 remaining
unmodified fields. Etc.

I suppose you will need some global variables (maybe an array?) to keep
track of which fields have been modified/marked; and you will probably
need a Reset button to reset the fields to the default 20% and unmark all
fields, if the user wants to start over; and you probably want to round to
2 decimals to force the math to be exactly right.

Ok, maybe the code gets a little complicated. Should be possible, however.

"richard" <no****@myplace .net> wrote in message
news:xJ******** **********@news-server.bigpond. net.au...
I have a table with 5 fields into which the user will enter numbers,
which must add up to 100%. Say the fields are Toyotas, Missans, Mazdas,
Hondas and Other. I am having trouble writing a query using Sum which
will add these together and place the result in another field called
"total" which I will then place on a form so the user can check it
contains value 100 for each record. Any help appreciated, thanks.


Nov 13 '05 #8

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

Similar topics

2
4010
by: Phil Powell | last post by:
Relevancy scores are normally defined by a MySQL query on a table that has a fulltext index. The rules for relevancy scoring will exclude certain words due to their being too short (minimum default is 4 letters). This is the Fed. Everything is a TLA (three-letter acronym). Therefore, since I'm building a PORTABLE web application, changing MySQL's default settings for fulltext index querying is completely undoable and unrealistic, so...
1
9989
by: Building Blocks | last post by:
Hi, All I need is a simle calculate form script which contains this: A script that can handle text input, radio buttons, checkboxes, and dropdowns. Each one of these variables will contain a number. That number will appear in a seperate box at the bottom. So basically whatever you choose has a corresponding number associated with it (except for the text input, which you enter whatever number) and those numbers are added and produced in...
11
2600
by: hazz | last post by:
before I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way... I will have a table with up to 300 rules in it. Maybe more... In each Score table there is a column which will refer to a domain specific table and another table column that contains the property of that domain specific object. IceCream is a domain and scoops is a property I...
2
2638
by: Pixie Songbook | last post by:
Hi, I have a progarm which models some data I'm working with using a gaussian profile and then calculates chi-squared in order to compare the gaussian values to the real thing. I want to minimise chi-squared using the arbitrary parameter I have edfined as 'K', problem is I have no idea how to proceed and the book I have doesn't explain it very well. For clarity the data I am working with consists of 2 columns of numbers representing wavelengths...
4
2746
by: Sector 7G | last post by:
I'm working with a SQL query for a Human Resources database. Its intended purpose is to find all the paycheck records with a check date (prckhist.chkdate ) more recent than eleven days past the employee's last raise (hrpersnl.p_paydate). It then totals the hours the employee worked from those records (prdehist.units), and if the total is within 40 hours of a threshold (hrpersnl.p_jmisc3) then the employee's name and information is returned, and...
3
5260
by: erikcw | last post by:
Hi, I'm getting the following error when I try to pass a list into a function. My List: crea = Traceback (most recent call last): File "wa.py", line 118, in ? curHandler.walkData()
3
1801
by: Widge | last post by:
I have made a spreadsheet that will calculate the distance from a set of addresses to a specified postcode in Excel. I'm looking to move this to Access so I can start thinking about hooking it up to a webpage. The main problem is the fact that I don't have a CLUE how to perform the lookup in Access. Basically we have 3 sheets. 1) where you enter your postcode and radius to search by, 2) a list of suppliers, their addresses and postcodes ... with...
5
2723
by: brendanmcdonagh | last post by:
Hi, I have been learning VB now for about a week and thought I was doing ok. I have already done a calculation form (not as big as this) . I have volunteered myself to help a friend input her hours per day into a form, start time, end time and lunch time. Then the form will calculate the amount of hours she has done for her. Sending results to access is not an issue yet! When I have entered the below code and tested it, it let's me input...
12
9137
by: denveromlp | last post by:
Hello, I'm new to Access and trying to calculate a rolling 12 month average from some time data. Each data point is a date and a measurement taken at that date. As far as I can tell, the only way to take the rolling average is to create a make-table of all the data points within the last year. Then create a query to pull out the minimum date, create a second query to pull out the maximum date, create a thrid query to pull out the...
3
1767
by: strangetorpedo | last post by:
The problem lies under where if (choice == '2') is...I need the program to keep prompting for num and den values as long as the user enters values less than or equal to 0. Once they are values greater than zero, the program is supposed to carry on and calculate the log, etc. HELP?! #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <math.h> #define PI 3.14159
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7745
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.