InfoPath sum

G

Goh

Where should I write a function that able to sum up fields,1 fields2 and
fields3 and store into fields4. I should use rules/action or writing code.

If writing code any examples that work like that?

Thanks anyway.
With regards
Goh
 
S

S.Y.M. Wong-A-Ton

No need to write code. If you are summing over 1 field in a repeating table,
you can use the sum() function in e.g. the footer of the repeating table (see
http://office.microsoft.com/en-ca/assistance/HP010969031033.aspx).

Since it sounds as though you have 3 separate fields, you can just use the
"+" operator in a formula. Set a rule on each one of the 3 fields with an
action that sets the value of field4 to the result of the formula: field1 +
field2 + field3.
 
G

Goh

Hi Wong,

Is not in repeating table. So how to write a code? or actually I
also have a way to sum it out without writing any code.

Thank in advance,
Goh
 
G

Goh

I found the way to sum it out, but seem that is ungly. need to make a lot of
rules to get it done. I think to done this by using coding who actually the
sum can be done in coding.

With regards,
Goh
 
S

S.Y.M. Wong-A-Ton

If you do the calculation in code, you have to add an OnAfterChange event
handler for each one of the 3 fields (field1, field2, and field3), so that if
the value of any of those fields changes, field4 will be recalculated. So
this would be equivalent to adding the 3 rules if you don't write code. As
you can see, it is not more elegant. And why write code when you can use
rules that can do the same thing?

If you insist on writing code, there are many samples in this newsgroup on
using the OnAfterChange event handler, retrieving a field's value, and
setting a value to a field. Do a search on "OnAfterChange" and
"selectSingleNode". You can also find examples on my website:
http://enterprise-solutions.swits.net/infopath/
 
G

Goh

Really Thanks

With regards,
Goh

S.Y.M. Wong-A-Ton said:
If you do the calculation in code, you have to add an OnAfterChange event
handler for each one of the 3 fields (field1, field2, and field3), so that
if
the value of any of those fields changes, field4 will be recalculated. So
this would be equivalent to adding the 3 rules if you don't write code. As
you can see, it is not more elegant. And why write code when you can use
rules that can do the same thing?

If you insist on writing code, there are many samples in this newsgroup on
using the OnAfterChange event handler, retrieving a field's value, and
setting a value to a field. Do a search on "OnAfterChange" and
"selectSingleNode". You can also find examples on my website:
http://enterprise-solutions.swits.net/infopath/
 

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