<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: repeating table calculations</title><link>https://www.infopathdev.com:443/forums/thread/13757.aspx</link><pubDate>Wed, 12 Oct 2005 23:39:32 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13757</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13757.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13757</wfw:commentRss><description>I'm not a VB person so I might have some issues with my code changes... but the concept I was trying to put across is that when you are working with repeating tables/sections you need to get fields relative to the one in the current row... not go all the way back to the top and work down -- that just brings you back to the first item.&lt;br /&gt;&lt;br /&gt;- - - - -&lt;br /&gt;&lt;br /&gt;Creating a row ID might be interesting if you have reasons for one... but many schemas are fixed and you can't add one. The best thing is to work relative to the item that cuased the OnAfterChange event.&lt;br /&gt;&lt;br /&gt;The other thing that you will probably want to consider is that OnAfterChange receives 2 events -- one for Delete and one for Insert. You want to filter out the Delete events by returning from the handler if e.Operation is not equal to "Insert".&lt;br /&gt;&lt;br /&gt;Greg Collins [InfoPath MVP]&lt;br /&gt;InfoPath Dev</description></item><item><title>Re: repeating table calculations</title><link>https://www.infopathdev.com:443/forums/thread/13756.aspx</link><pubDate>Tue, 11 Oct 2005 17:34:05 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13756</guid><dc:creator>puziuss</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13756.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13756</wfw:commentRss><description>Thank you Greg but nope, that does not work at all, not even for the first row. When I made your suggested changes I got an error "Object reference not set to an instance of an object" and a warning in VS I had mentioned before.  &lt;br /&gt;Anyway, what do you think about this: &lt;a href='http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=962' target='_blank' title='http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=962'&lt;a target="_blank" href=http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=962&gt;http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=962&lt;/a&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote id="quote"&gt;&lt;font size="1" face="Verdana, Arial, Helvetica" id="quote"&gt;quote:&lt;hr height="1" noshade id="quote"&gt;&lt;i&gt;Originally posted by Greg Collins&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;You are using absolute paths in your code. That is why you are always getting the first instance of the nodes. Your OnAfterChange event is already pointing to the correct field1... you just need to get the sibling field2 and field3... not go all the way back to the top of the tree...&lt;br /&gt;&lt;br /&gt;There may be other issues too, but try the following changes:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Public Sub field1_OnAfterChange(ByVal e As DataDOMEvent)&lt;br /&gt;&lt;br /&gt;Dim field1 As Double = _&lt;br /&gt;CDbl(e.Source.text)&lt;br /&gt;&lt;br /&gt;Dim field2 As Double = _&lt;br /&gt;CDbl(e.Source.selectSingleNode("../my:field2").text)&lt;br /&gt;&lt;br /&gt;Dim nodeField3 As IXMLDOMNode = _&lt;br /&gt;e.Source.selectSingleNode("../my:field3")&lt;br /&gt;&lt;br /&gt;Dim field3 As Double &lt;br /&gt;&lt;br /&gt;field3 = SubtotalCalc (field1, field2)&lt;br /&gt;&lt;br /&gt;nodeField3.text = CStr(field3)&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Greg Collins [InfoPath MVP]&lt;br /&gt;InfoPath Dev&lt;br /&gt;&lt;hr height="1" noshade id="quote"&gt;&lt;/font id="quote"&gt;&lt;/blockquote id="quote"&gt;</description></item><item><title>Re: repeating table calculations</title><link>https://www.infopathdev.com:443/forums/thread/13755.aspx</link><pubDate>Tue, 11 Oct 2005 17:02:23 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13755</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13755.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13755</wfw:commentRss><description>You are using absolute paths in your code. That is why you are always getting the first instance of the nodes. Your OnAfterChange event is already pointing to the correct field1... you just need to get the sibling field2 and field3... not go all the way back to the top of the tree...&lt;br /&gt;&lt;br /&gt;There may be other issues too, but try the following changes:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Public Sub field1_OnAfterChange(ByVal e As DataDOMEvent)&lt;br /&gt;&lt;br /&gt;Dim field1 As Double = _&lt;br /&gt;CDbl(e.Source.text)&lt;br /&gt;&lt;br /&gt;Dim field2 As Double = _&lt;br /&gt;CDbl(e.Source.selectSingleNode("../my:field2").text)&lt;br /&gt;&lt;br /&gt;Dim nodeField3 As IXMLDOMNode = _&lt;br /&gt;e.Source.selectSingleNode("../my:field3")&lt;br /&gt;&lt;br /&gt;Dim field3 As Double &lt;br /&gt;&lt;br /&gt;field3 = SubtotalCalc (field1, field2)&lt;br /&gt;&lt;br /&gt;nodeField3.text = CStr(field3)&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Greg Collins [InfoPath MVP]&lt;br /&gt;InfoPath Dev</description></item><item><title>Re: repeating table calculations</title><link>https://www.infopathdev.com:443/forums/thread/13754.aspx</link><pubDate>Tue, 11 Oct 2005 14:46:49 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13754</guid><dc:creator>puziuss</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13754.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13754</wfw:commentRss><description>Yes, I have tried that and many other possible ways of referencing table fields. Only "//my:fieldX" works for the first row at least nothing else does.&lt;br /&gt;&lt;br /&gt;Thanks for any suggestions!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote id="quote"&gt;&lt;font size="1" face="Verdana, Arial, Helvetica" id="quote"&gt;quote:&lt;hr height="1" noshade id="quote"&gt;&lt;i&gt;Originally posted by franck&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Hi,&lt;br /&gt;&lt;br /&gt;Have you just tried: "my:fieldX" inside your SelectSingleNode?&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;&lt;br /&gt;Franck Dauché&lt;br /&gt;&lt;hr height="1" noshade id="quote"&gt;&lt;/font id="quote"&gt;&lt;/blockquote id="quote"&gt;</description></item><item><title>Re: repeating table calculations</title><link>https://www.infopathdev.com:443/forums/thread/13753.aspx</link><pubDate>Tue, 11 Oct 2005 01:40:58 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13753</guid><dc:creator>franck</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13753.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13753</wfw:commentRss><description>Hi,&lt;br /&gt;&lt;br /&gt;Have you just tried: "my:fieldX" inside your SelectSingleNode?&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;&lt;br /&gt;Franck Dauché</description></item><item><title>repeating table calculations</title><link>https://www.infopathdev.com:443/forums/thread/12612.aspx</link><pubDate>Mon, 10 Oct 2005 21:58:32 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12612</guid><dc:creator>puziuss</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12612.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12612</wfw:commentRss><description>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):&lt;br /&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;Public Sub field1_OnAfterChange(ByVal e As DataDOMEvent)&lt;br /&gt;&lt;br /&gt;Dim field1 As Double = _&lt;br /&gt;CDbl(e.Source.selectSingleNode("/my:myFields/my:group1/my:group2/my:field1").text)&lt;br /&gt;&lt;br /&gt;Dim field2 As Double = _&lt;br /&gt;CDbl(e.Source.selectSingleNode("/my:myFields/my:group1/my:group2/my:field2").text)&lt;br /&gt;&lt;br /&gt;Dim nodeField3 As IXMLDOMNode = _&lt;br /&gt;e.Source.selectSingleNode("/my:myFields/my:group1/my:group2/my:field3")&lt;br /&gt;&lt;br /&gt;Dim field3 As Double &lt;br /&gt;&lt;br /&gt;field3 = SubtotalCalc (field1, field2)&lt;br /&gt;&lt;br /&gt;nodeField3.text = CStr(field3)&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Following Greg's advise a while ago (&lt;a href='http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=171&amp;SearchTerms=relative,paths' target='_blank' title='http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=171&amp;SearchTerms=relative,paths'&lt;a target="_blank" href=http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=171&amp;SearchTerms=relative&gt;http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=171&amp;SearchTerms=relative&lt;/a&gt;,paths&lt;/a&gt;) 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? &lt;br /&gt;&lt;br /&gt;Also, I always get following warning when I build my solution in VS:&lt;br /&gt;&lt;br /&gt;"A first chance exception of type 'System.NullReferenceException' occurred in InfoPathProject1.dll". &lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;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. &lt;br /&gt;&lt;br /&gt;I would appreciate if somebody could help me, please!!! I am new to InfoPath...</description></item></channel></rss>