Calculated Control

F

F Jolivette

I have a problem with a caculated control that returns the wrong sum when I
add numbers but returns the correct sum when I multiply, divide, or subtract
the same two numbers. I am caculating figures stored in unbound controls on
a form that isn't related to a table. For instance [Control1] + [Control2]
returns 2.57.5
The value in Control1 is 2.5 and the value in Control2 is 7.5
Can anyone explain why this happening and provide a solution to the problem.
 
D

Douglas J Steele

And the solution is to use CSng([Control1]) + CSng([Control2])

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Rick B said:
Yes. They are text fields, not numbers.

They are being concatenated.

--
Rick B



F Jolivette said:
I have a problem with a caculated control that returns the wrong sum
when
I
add numbers but returns the correct sum when I multiply, divide, or subtract
the same two numbers. I am caculating figures stored in unbound
controls
on
a form that isn't related to a table. For instance [Control1] + [Control2]
returns 2.57.5
The value in Control1 is 2.5 and the value in Control2 is 7.5
Can anyone explain why this happening and provide a solution to the problem.
 
S

SusanV

Rereading your post I just noticed you are trying to sum calculated
controls - unfortunately you can't do that directly. There are workarounds
though, take a look at this article:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;207763

--
hth,
SusanV


Rick B said:
Yes. They are text fields, not numbers.

They are being concatenated.

--
Rick B



F Jolivette said:
I have a problem with a caculated control that returns the wrong sum when I
add numbers but returns the correct sum when I multiply, divide, or subtract
the same two numbers. I am caculating figures stored in unbound controls on
a form that isn't related to a table. For instance [Control1] +
[Control2]
returns 2.57.5
The value in Control1 is 2.5 and the value in Control2 is 7.5
Can anyone explain why this happening and provide a solution to the problem.
 
S

SusanV

Oooh, goody a new thing learned! Thanks Doug!

Douglas J Steele said:
And the solution is to use CSng([Control1]) + CSng([Control2])

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Rick B said:
Yes. They are text fields, not numbers.

They are being concatenated.

--
Rick B



F Jolivette said:
I have a problem with a caculated control that returns the wrong sum
when
I
add numbers but returns the correct sum when I multiply, divide, or subtract
the same two numbers. I am caculating figures stored in unbound
controls
on
a form that isn't related to a table. For instance [Control1] + [Control2]
returns 2.57.5
The value in Control1 is 2.5 and the value in Control2 is 7.5
Can anyone explain why this happening and provide a solution to the problem.
 
F

F Jolivette

That work! Thanks!
--
Fabien Jolivette


KARL DEWEY said:
I tried it and found why. It thinks they are text and therefore concatenates.
Use this and it will add --
=(Val([Control1])+Val([Control2]))

By using Val you tell the data is numerials and not text.

F Jolivette said:
This is a form that isn't linked to any qry or table. I'm using Unbound
controls to enter values and then a calculated control that adds the sum of a
these controls. What I don't understand is why it's concatenating when I use
the "+" sign and performing calculations when using all other signs.
--
Fabien Jolivette


KARL DEWEY said:
It look like it is concatenating instead of adding.

Where are you displaying this - query, form, or report?

:

When I try Sum([Control1] + [Control2]), it returns #Error.
If I use the syntax [Control1] + [Control2], it returns the wrong value
unless I use -,*, or / signs.
--
Fabien Jolivette


:

What is your actual syntax?

Is it Sum([Control1] + [Control2]) ?

:

I have a problem with a caculated control that returns the wrong sum when I
add numbers but returns the correct sum when I multiply, divide, or subtract
the same two numbers. I am caculating figures stored in unbound controls on
a form that isn't related to a table. For instance [Control1] + [Control2]
returns 2.57.5
The value in Control1 is 2.5 and the value in Control2 is 7.5
Can anyone explain why this happening and provide a solution to the problem.
 
K

KARL DEWEY

I tried it and found why. It thinks they are text and therefore concatenates.
Use this and it will add --
=(Val([Control1])+Val([Control2]))

By using Val you tell the data is numerials and not text.

F Jolivette said:
This is a form that isn't linked to any qry or table. I'm using Unbound
controls to enter values and then a calculated control that adds the sum of a
these controls. What I don't understand is why it's concatenating when I use
the "+" sign and performing calculations when using all other signs.
--
Fabien Jolivette


KARL DEWEY said:
It look like it is concatenating instead of adding.

Where are you displaying this - query, form, or report?

F Jolivette said:
When I try Sum([Control1] + [Control2]), it returns #Error.
If I use the syntax [Control1] + [Control2], it returns the wrong value
unless I use -,*, or / signs.
--
Fabien Jolivette


:

What is your actual syntax?

Is it Sum([Control1] + [Control2]) ?

:

I have a problem with a caculated control that returns the wrong sum when I
add numbers but returns the correct sum when I multiply, divide, or subtract
the same two numbers. I am caculating figures stored in unbound controls on
a form that isn't related to a table. For instance [Control1] + [Control2]
returns 2.57.5
The value in Control1 is 2.5 and the value in Control2 is 7.5
Can anyone explain why this happening and provide a solution to the problem.
 
K

KARL DEWEY

It look like it is concatenating instead of adding.

Where are you displaying this - query, form, or report?

F Jolivette said:
When I try Sum([Control1] + [Control2]), it returns #Error.
If I use the syntax [Control1] + [Control2], it returns the wrong value
unless I use -,*, or / signs.
--
Fabien Jolivette


KARL DEWEY said:
What is your actual syntax?

Is it Sum([Control1] + [Control2]) ?

F Jolivette said:
I have a problem with a caculated control that returns the wrong sum when I
add numbers but returns the correct sum when I multiply, divide, or subtract
the same two numbers. I am caculating figures stored in unbound controls on
a form that isn't related to a table. For instance [Control1] + [Control2]
returns 2.57.5
The value in Control1 is 2.5 and the value in Control2 is 7.5
Can anyone explain why this happening and provide a solution to the problem.
 
F

F Jolivette

When I try Sum([Control1] + [Control2]), it returns #Error.
If I use the syntax [Control1] + [Control2], it returns the wrong value
unless I use -,*, or / signs.
--
Fabien Jolivette


KARL DEWEY said:
What is your actual syntax?

Is it Sum([Control1] + [Control2]) ?

F Jolivette said:
I have a problem with a caculated control that returns the wrong sum when I
add numbers but returns the correct sum when I multiply, divide, or subtract
the same two numbers. I am caculating figures stored in unbound controls on
a form that isn't related to a table. For instance [Control1] + [Control2]
returns 2.57.5
The value in Control1 is 2.5 and the value in Control2 is 7.5
Can anyone explain why this happening and provide a solution to the problem.
 
F

F Jolivette

This is a form that isn't linked to any qry or table. I'm using Unbound
controls to enter values and then a calculated control that adds the sum of a
these controls. What I don't understand is why it's concatenating when I use
the "+" sign and performing calculations when using all other signs.
--
Fabien Jolivette


KARL DEWEY said:
It look like it is concatenating instead of adding.

Where are you displaying this - query, form, or report?

F Jolivette said:
When I try Sum([Control1] + [Control2]), it returns #Error.
If I use the syntax [Control1] + [Control2], it returns the wrong value
unless I use -,*, or / signs.
--
Fabien Jolivette


KARL DEWEY said:
What is your actual syntax?

Is it Sum([Control1] + [Control2]) ?

:

I have a problem with a caculated control that returns the wrong sum when I
add numbers but returns the correct sum when I multiply, divide, or subtract
the same two numbers. I am caculating figures stored in unbound controls on
a form that isn't related to a table. For instance [Control1] + [Control2]
returns 2.57.5
The value in Control1 is 2.5 and the value in Control2 is 7.5
Can anyone explain why this happening and provide a solution to the problem.
 

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