A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

adding fields in query



 
 
Thread Tools Display Modes
  #1  
Old May 5th, 2010, 12:25 PM posted to microsoft.public.access.gettingstarted
janelgirl
external usenet poster
 
Posts: 8
Default adding fields in query

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
  #2  
Old May 5th, 2010, 12:38 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 7,815
Default adding fields in query

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

  #3  
Old May 6th, 2010, 03:57 PM posted to microsoft.public.access.gettingstarted
janelgirl
external usenet poster
 
Posts: 8
Default adding fields in query

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

.

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:29 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.