I am trying to calculate subtotals for each row in the repeating table but I can get it to work only for the first row! I need to do calculations using managed code because there is some looping etc. involved. Here is a simplified example of my code (in VB.Net):
Public Sub field1_OnAfterChange(ByVal e As DataDOMEvent)
Dim field1 As Double = _
CDbl(e.Source.selectSingleNode("/my:myFields/my:group1/my:group2/my:field1").text)
Dim field2 As Double = _
CDbl(e.Source.selectSingleNode("/my:myFields/my:group1/my:group2/my:field2").text)
Dim nodeField3 As IXMLDOMNode = _
e.Source.selectSingleNode("/my:myFields/my:group1/my:group2/my:field3")
Dim field3 As Double
field3 = SubtotalCalc (field1, field2)
nodeField3.text = CStr(field3)
End Sub
Following Greg's advise a while ago (
http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=171&SearchTerms=relative,paths) I tried using relative paths instead of absolute paths. I changed my paths to ("../fieldName") but then function SubtotalCalc is never executed - not even for the first row:( What am I doing wrong?
Also, I always get following warning when I build my solution in VS:
"A first chance exception of type 'System.NullReferenceException' occurred in InfoPathProject1.dll".
It doesn't seem to affect the form when it is opened in InfoPath though - no error messages are displayed and form works just fine.
I tried to inlcude code in If ... Then statement to make sure the nodes can be found in XDocument and used Try ... Catch block to handle exeptions - no change.
I would appreciate if somebody could help me, please!!! I am new to InfoPath...