adding fields in query

J

janelgirl

I am trying to add fields in a query to put into a new field. For example;
FieldOne, FieldTwo, and FieldThree should equal FieldFour. FieldOne has a
value of 1, FieldTwo has a value of 2 and FieldThree has a value of 3. When
I try =FieldOne+FieldTwo+FieldThree in FieldFour with the expression builder,
it does not add them, it just shoves all their values together. Instead of
FieldFour having a value of 6 when I run the query, it gives me a value of
123. I have also tried the "&" instead of "+", and I get the same results.
I have tried changing the Total line to Sum, Group By, Expression, and Count.
the query still does the same thing. Access is fairly new to me, so I am
sure that there is a simple solution that I am overlooking. Any help
provided would be great. TIA
 
J

John Spencer

It sounds as if the fields are being treated as if they are TEXT fields.

Try using the Val function or one of the conversion functions (Cdbl) to force
the conversion of the text to a number. Of course this will fail if the fields
are ever null (blank) or contain a non-numeric value.

=CDbl(FieldOne)+CDbl(FieldTwo)+CDbl(FieldThree)

To handle nulls in a field combine the VAL function with the NZ function
Val(Nz(FieldOne,0))


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
J

janelgirl

Thank you so much!! They were set as TEXT fields, and once I adjusted that,
it added correctly. This really helped me from pulling out the remainder of
my hair! Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top