View Full Version : Sub totals on forms


tppatter
10-23-2001, 04:32 AM
On my form I have a sub-total field. I simply want the sub-total form to sum all the price extended fields for each product. I have tried the formula me.subtotal=me.field1+me.field2, etc.
But no total is appearing in the sub total field. Thanks in advance for any help someone might be able to provide.

Rich
10-23-2001, 05:02 AM
Put the following in the Form Current event proc.
me.subtotal=me.field1+me.field2
In the after update event of fields 1,2,etc put Form_Current
HTH

tppatter
10-23-2001, 06:23 AM
I did what you had suggested, but the subtotal is reading the numbers together, rather then adding them together (eg. 141516, when it should read 45)

Also, I have 10 fields that would be added to get a sub-total. Many times less then 10 fields will be filled in. I would like the sub-total to read the total as the different fields are entered in (eg. 1st field is entered as 20, then the sub-total reads 20, 2nd field is entered as 30, then the sub-total changes to 50, etc.).

Thanks in advance for any help you might be able to provide

Pat Hartman
10-23-2001, 07:04 AM
For some reason, Access is interpreting the values as text and concatenating them rather than adding them. Try using the Val() function.

me.subtotal = val(me.field1) + val(me.field2) + ....

As Rich suggested, the above statement goes in the Current event of the form. Since you want a running total, you'll need to execute the code in the AfterUpdate event of each of the fields. To do that, you can call the form's current event -

Call Form_Current