PC Review


Reply
Thread Tools Rate Thread

adding fields in query

 
 
janelgirl
Guest
Posts: n/a
 
      5th May 2010
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
 
Reply With Quote
 
 
 
 
John Spencer
Guest
Posts: n/a
 
      5th May 2010
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

janelgirl wrote:
> 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

 
Reply With Quote
 
janelgirl
Guest
Posts: n/a
 
      6th May 2010
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.

"John Spencer" wrote:

> 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
>
> janelgirl wrote:
> > 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

> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding fields from a different query Anne D. Microsoft Access Forms 6 20th Nov 2009 04:31 PM
Adding fields in a query =?Utf-8?B?QXVyb3Jh?= Microsoft Access Reports 1 27th Jan 2007 01:24 PM
COUNT QUERY in make query table adding fields. =?Utf-8?B?RWxyaWM=?= Microsoft Access Queries 0 10th Jan 2005 02:27 AM
Adding fields to a Query Please Help Microsoft Access Queries 0 6th Apr 2004 08:09 PM
adding fields in a query... needsomehelppls Microsoft Access 2 18th Aug 2003 04:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:21 AM.