Mattymatt79
04-23-2002, 09:13 AM
Ok, again another probably really easy question
im trying to add a bunch of fields together to get a total of all the numbers
whenever i do it, it gives me the numbers right next to each other.
if i do any other kind of function it does it, but the addition one just puts the numbers right next to each other
any thing im doing wrong?
David R
04-23-2002, 09:41 AM
Are your numbers actually numeric fields, or are they text numbers?
Are you using + or & for addition?
Either of the latter could cause problems. Maybe post an example of what you're doing.
Mattymatt79
04-25-2002, 03:59 AM
all im doing is adding a few fields that have numeric values together
like imputing the ammount of people involved and stuff and its through i think 4 fields and i want to total it
no matter how i word the expression it just puts the numbers back to back to back.
the multiplication and subtraction and division work perfectly dont know what im doing when it comes to addition
I think what David meant was post the expression that's not working so we can see what you have
have you tried
= Sum([text1]+[text2]+[text3]+[text4])
Pat Hartman
04-25-2002, 04:39 PM
Are you sure that the fields are defined as numeric? The Plus (+) operator will concatenate text fields much like the Ampersand (&) operator does.
Also, if any of the fields may be null, you'll need to use the Nz() function.
YourTotal:Nz([text1],0)+Nz([text2],0)+Nz([text3],0)+Nz([text4],0)
DBL, you don't use the Sum() function to add a series of columns together, the aggregate functions work on all rows of a single column. The statement you wrote is correct in a totals query if you want to add 4 columns together and then get the sum of all rows although you still need to worry about nulls. I could be wrong but, I don't think that Mattymat was asking about summing rows, I think that he just wanted to add some columns together.
Mattymatt79
04-26-2002, 09:33 AM
the function im using is this
sum[total]=[udp/deployed]+[forwardbased]+[forwardstationed]+[deployedfortraining]
every time ive changed it, i continue to get the number next to each other... but if i change + to - or * or / it works but not with the adding... i still cant figure out what im doing wrong
Have you managed to solve this yet? If not, and the database isn't too big, send it on and I'll have a fiddle.
Mattymatt79
04-29-2002, 03:44 AM
i cant send the database... its on a seceret site and i just plain cant
ill write down here exactly what im trying to do
the query is all taken from the same table
now maybe where im screwing up is the grouping of the numbers
the fields are correct i pulled them right off the table list.
udp/deployed forwardS forwardB Deployed
global global global global
sum sum sum sum
now the expression im using is
expr1: sum([total]=[udp/deployed]+[forwardS]+[forwardB]+[Deployed])
ok now whenever i take out the + and change it with - / * it works the numbers compute correctly... now what the heck am i doing to make it put the numbers all next to each other? it puts it into the total field like i want it too, but it puts them together?
im not using the & or and im just using the + what am i doing wrong? im pulling out my hair about this... well what little hair i have
David R
04-29-2002, 11:27 AM
Is this a query field, Matt? Try:
SumTotal: [udp/deployed]+[forwardS]+[forwardB]+[Deployed]
"Expr1" is the default name for a calculated expression in an Access Query. The colon separates the 'name' from the calculation.
As Pat said, Sum() is not what you want in this case I don't believe. If the above doesn't work and you're dealing with text fields, not numeric, then try surrounding each one with Val(). That'll definitely convert them to numbers, if it can.
[This message has been edited by David R (edited 04-29-2002).]
Mattymatt79
05-06-2002, 09:47 AM
tried the Val() and the totalsum() neither worked... i have no idea i must have done something totally screwed up and i really dont know how to fix it... sad i cant even do an add query
expublish
05-27-2002, 06:37 AM
Your problem is as other have already pointed out. The fields you are trying to add together are text fields. You can't do an add query with text fields. Change them to numeric fields and I am 99% sure it will work.
I had the same problem.
Scott.