Adding function is being dumb

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have to fields that data is inputted to and want to add them up and put the
output in another field. My equation is as follows:

EndMonth: [Apr On Hand]+[Apr Ordered Amount]

I have my output field set to EndMonth but when I input values into the Apr
On Hand and Apr Ordered Amount fields it doesnt add them, it combines them.
Say I put a 2 in AOH and a 5 in AOA, instead of giving me seven it gives me
25. If I subtract, multiply or divide it works ok. Is there a different
symbol I need to put in place of the +?
 
Then they must be TEXT fields, not NUMERIC.

Make then Numeric fields.
 
Sounds as if the query thinks the Apr On Hand and Apr Ordered Amount values
are strings, not numbers. I take it that these are parameters that you enter
when you run the query?

Try this (using CDbl function to change the inputted values into numbers):
EndMonth: CDbl([Apr On Hand])+CDbl([Apr Ordered Amount])
 
If the fields hold integer values, I'd recommend using CLng instead of CDbl.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


Ken Snell said:
Sounds as if the query thinks the Apr On Hand and Apr Ordered Amount values
are strings, not numbers. I take it that these are parameters that you enter
when you run the query?

Try this (using CDbl function to change the inputted values into numbers):
EndMonth: CDbl([Apr On Hand])+CDbl([Apr Ordered Amount])


--

Ken Snell
<MS ACCESS MVP>

nbuwalda said:
I have to fields that data is inputted to and want to add them up and put
the
output in another field. My equation is as follows:

EndMonth: [Apr On Hand]+[Apr Ordered Amount]

I have my output field set to EndMonth but when I input values into the
Apr
On Hand and Apr Ordered Amount fields it doesnt add them, it combines
them.
Say I put a 2 in AOH and a 5 in AOA, instead of giving me seven it gives
me
25. If I subtract, multiply or divide it works ok. Is there a different
symbol I need to put in place of the +?
 
Agreed for an integer number ... in my post, I didn't want to assume that
the number was a whole number and then have an additional post about
truncation occurring.

< g >

--

Ken Snell
<MS ACCESS MVP>



Roger Carlson said:
If the fields hold integer values, I'd recommend using CLng instead of
CDbl.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


Ken Snell said:
Sounds as if the query thinks the Apr On Hand and Apr Ordered Amount values
are strings, not numbers. I take it that these are parameters that you enter
when you run the query?

Try this (using CDbl function to change the inputted values into
numbers):
EndMonth: CDbl([Apr On Hand])+CDbl([Apr Ordered Amount])


--

Ken Snell
<MS ACCESS MVP>

nbuwalda said:
I have to fields that data is inputted to and want to add them up and
put
the
output in another field. My equation is as follows:

EndMonth: [Apr On Hand]+[Apr Ordered Amount]

I have my output field set to EndMonth but when I input values into the
Apr
On Hand and Apr Ordered Amount fields it doesnt add them, it combines
them.
Say I put a 2 in AOH and a 5 in AOA, instead of giving me seven it
gives
me
25. If I subtract, multiply or divide it works ok. Is there a different
symbol I need to put in place of the +?
 
As I assumed. I only piped in because the field names led me to believe
they were integer.

However, another thought just occurred to me. Isn't it true that storing
integer values in Double-precision variables and then doing math on them
sometimes introduces rounding errors? I can't find my source, but the
solution (as I recall) was to use Currency instead. Does this ring a bell
with you?

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L



Ken Snell said:
Agreed for an integer number ... in my post, I didn't want to assume that
the number was a whole number and then have an additional post about
truncation occurring.

< g >

--

Ken Snell
<MS ACCESS MVP>



Roger Carlson said:
If the fields hold integer values, I'd recommend using CLng instead of
CDbl.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


Ken Snell said:
Sounds as if the query thinks the Apr On Hand and Apr Ordered Amount values
are strings, not numbers. I take it that these are parameters that you enter
when you run the query?

Try this (using CDbl function to change the inputted values into
numbers):
EndMonth: CDbl([Apr On Hand])+CDbl([Apr Ordered Amount])


--

Ken Snell
<MS ACCESS MVP>

I have to fields that data is inputted to and want to add them up and
put
the
output in another field. My equation is as follows:

EndMonth: [Apr On Hand]+[Apr Ordered Amount]

I have my output field set to EndMonth but when I input values into the
Apr
On Hand and Apr Ordered Amount fields it doesnt add them, it combines
them.
Say I put a 2 in AOH and a 5 in AOA, instead of giving me seven it
gives
me
25. If I subtract, multiply or divide it works ok. Is there a different
symbol I need to put in place of the +?
 
Yes, Double might cause a bit of rounding, though significantly less than
using Single (as I've found out the hard way :-( in an application).
Currency could work as well and would also greatly reduce rounding.


Roger Carlson said:
As I assumed. I only piped in because the field names led me to believe
they were integer.

However, another thought just occurred to me. Isn't it true that storing
integer values in Double-precision variables and then doing math on them
sometimes introduces rounding errors? I can't find my source, but the
solution (as I recall) was to use Currency instead. Does this ring a bell
with you?

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L



Ken Snell said:
Agreed for an integer number ... in my post, I didn't want to assume that
the number was a whole number and then have an additional post about
truncation occurring.

< g >

--

Ken Snell
<MS ACCESS MVP>



Roger Carlson said:
If the fields hold integer values, I'd recommend using CLng instead of
CDbl.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


Sounds as if the query thinks the Apr On Hand and Apr Ordered Amount
values
are strings, not numbers. I take it that these are parameters that you
enter
when you run the query?

Try this (using CDbl function to change the inputted values into
numbers):
EndMonth: CDbl([Apr On Hand])+CDbl([Apr Ordered Amount])


--

Ken Snell
<MS ACCESS MVP>

I have to fields that data is inputted to and want to add them up and
put
the
output in another field. My equation is as follows:

EndMonth: [Apr On Hand]+[Apr Ordered Amount]

I have my output field set to EndMonth but when I input values into the
Apr
On Hand and Apr Ordered Amount fields it doesnt add them, it
combines
them.
Say I put a 2 in AOH and a 5 in AOA, instead of giving me seven it
gives
me
25. If I subtract, multiply or divide it works ok. Is there a
different
symbol I need to put in place of the +?
 

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

Back
Top