Summing txt boxes on a form ?

  • Thread starter Thread starter acs68
  • Start date Start date
A

acs68

Hi all,

I have 6 fields on a form that I want to add up. They are text fields.

Here's the ControlSource on an unbound Text Field:

=[txtFinBBFwd]+[txtFinLeviedThisYear]-[txtFinDiscount]-[txtFinPensionerRemission]-[txtFinCouncilRemission]-[txtFinPaid]

Comes up with #error

Is it possible to sum up these values ?

cheers,

Adam
 
acs68 said:
I have 6 fields on a form that I want to add up. They are text fields.

Here's the ControlSource on an unbound Text Field:

=[txtFinBBFwd]+[txtFinLeviedThisYear]-[txtFinDiscount]-[txtFinPensionerRemission]-[txtFinCouncilRemission]-[txtFinPaid]

Comes up with #error

Is it possible to sum up these values ?


Sure, as long as they're non-Null numeric values.

Make sure that this unbound text box is not named the same
as any of the fields in the expression.
 
Thanks Marshall,

still having problems though.

All controls have a value in them but it seems to be concatenating the
values, i.e. :
If I put "1" in txtFinBBFwd and "2" in txtFinLeviedThisYear

and in the control source of txtAddUp
"=[txtFinBBFwd]+[txtFinLeviedThisYear]"

I get "11" as the answer - should be "2"

any ideas ?

cheers,

Adam


Marshall Barton said:
acs68 said:
I have 6 fields on a form that I want to add up. They are text fields.

Here's the ControlSource on an unbound Text Field:

=[txtFinBBFwd]+[txtFinLeviedThisYear]-[txtFinDiscount]-[txtFinPensionerRemission]-[txtFinCouncilRemission]-[txtFinPaid]

Comes up with #error

Is it possible to sum up these values ?


Sure, as long as they're non-Null numeric values.

Make sure that this unbound text box is not named the same
as any of the fields in the expression.
 
Access thinks they are just text. Typecast them so it recognised them as
numbers, e.g.:
= CCur(Nz([txtFinBBFwd],0)) + CCur(Nz([txtFinLeviedThisYear], 0))

Explanation and other tips (such as setting the Format of the text boxes) in
article:
Calculated fields misinterpreted
at:
http://members.iinet.net.au/~allenbrowne/ser-45.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

acs68 said:
Thanks Marshall,

still having problems though.

All controls have a value in them but it seems to be concatenating the
values, i.e. :
If I put "1" in txtFinBBFwd and "2" in txtFinLeviedThisYear

and in the control source of txtAddUp
"=[txtFinBBFwd]+[txtFinLeviedThisYear]"

I get "11" as the answer - should be "2"

any ideas ?

cheers,

Adam


Marshall Barton said:
acs68 said:
I have 6 fields on a form that I want to add up. They are text fields.

Here's the ControlSource on an unbound Text Field:

=[txtFinBBFwd]+[txtFinLeviedThisYear]-[txtFinDiscount]-[txtFinPensionerRemission]-[txtFinCouncilRemission]-[txtFinPaid]

Comes up with #error

Is it possible to sum up these values ?


Sure, as long as they're non-Null numeric values.

Make sure that this unbound text box is not named the same
as any of the fields in the expression.
 
Back
Top