Adding text box values in report -

loo8866

Registered User.
Local time
Today, 14:28
Joined
Jan 11, 2007
Messages
106
Am I missing something simple here? I have several text boxes, which I want to add the values. I have tried these formulae, but dont work:

=Sum([Postage],[ProgTotal])

=Sum([Postage] + [ProgTotal])

=DSum([Postage],[ProgTotal])

Any help would be greatly appreciated!
 
The Sum function totals a field, not multiple fields. You're just trying to add two fields together, so this is it:

=[Postage] + [ProgTotal]

If you're trying to get the sum of Postage plus the sum of ProgTotal, then it's this:

=Sum([Postage]) + Sum([ProgTotal])
 
Thanks for the quick reply.

I actually tried =[Postage] + [ProgTotal], but it just gives me £1.50£1.00

I think the problem is that Postage and ProgTotal are the names of the text boxes (rather than the control source).

Should I be trying to say like Postage.value?
 
The problem is that they are text values and the plus sign is concatenating the two strings. Add a VAL to the expression.

=Val([Postage]) + Val([ProgTotal])

You should be storing numeric values as numbers in the first place, so you may want to alter the table design to accomodate that.
 
I've tried

=Val([Postage])+Val([ProgTotal])

However, I just get 0. should be £6.00 or something.

Im not actually storing these values, so theyr not being stored as text (regarding your advice).

Mmm, stuck - Thanks for your help, I'll have another fiddle with it.
 
If anyone could offer any advice as to why this above formula doesn't work - then it would be appreciated!
 
The problem is that the fields contain the pound character (£). The Val fails on the first non-numeric it encounters. For example:

Val("60as34") = 60
Val("£1.50") = 0

The second is true because it returns nothing. Therefore, it is in fact being stored as a string, and the Val function won't work, but CSng will. (CSng is convert to single.)

However, you probably want that pound symbol out to begin with, in which case you cut out the first character, like this:

=Val(Mid([Postage],2))+Val(Mid([ProgTotal],2))
 
Thats the one - thanks for all your help:

Cheers for now/
 

Users who are viewing this thread

Back
Top Bottom