Summing txt boxes on a form ?

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
 
M

Marshall Barton

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.
 
A

acs68

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.
 
A

Allen Browne

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.
 

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