<?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>Controls</title><link>https://www.infopathdev.com:443/forums/43.aspx</link><description> </description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: The 2nd row of a repeating table does not calculate fields via code behind?</title><link>https://www.infopathdev.com:443/forums/thread/53936.aspx</link><pubDate>Wed, 21 Apr 2010 01:23:09 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:53936</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/53936.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=43&amp;PostID=53936</wfw:commentRss><description>&lt;p&gt;The user won&amp;#39;t ever enter data in this field, right? Why not just hide it if it is NaN?&lt;/p&gt;</description></item><item><title>Re: The 2nd row of a repeating table does not calculate fields via code behind?</title><link>https://www.infopathdev.com:443/forums/thread/53903.aspx</link><pubDate>Tue, 20 Apr 2010 14:28:48 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:53903</guid><dc:creator>cdavis</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/53903.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=43&amp;PostID=53903</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Once again, you are brilliant!&amp;nbsp; After changing from absolute to relative it worked perfectly.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The handler variable was something I found in these forums.&amp;nbsp; I was having an issue with something about infinite loop possibilities (can&amp;#39;t remember the error) and saw a post where someone mention using that variable.&amp;nbsp; It worked perfectly.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Now I have to figure out how to get the default NaN out of calculated fields when I insert a new row.&amp;nbsp; I want the default to be 0.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks for the excellent help!&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Chris &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: The 2nd row of a repeating table does not calculate fields via code behind?</title><link>https://www.infopathdev.com:443/forums/thread/53802.aspx</link><pubDate>Sat, 17 Apr 2010 11:25:43 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:53802</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/53802.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=43&amp;PostID=53802</wfw:commentRss><description>&lt;p&gt;To run your JScript in debug, simply type &lt;strong&gt;debugger;&lt;/strong&gt; on a line before the code you want to be able to step through (thank goodness for &lt;a href="http://msdn.microsoft.com/en-us/library/bb250982.aspx?ppud=4"&gt;MSDN&lt;/a&gt;!). &lt;/p&gt;
&lt;p&gt;You are using absolute XPath, so that is going to be one problem you are having. I notice a variable called &amp;#39;handler&amp;#39; -- and you mention it is to prevent an infinite loop error? What was happening there?&lt;/p&gt;
&lt;p&gt;The OnAfterChange event is going to fire twice when your field changes, so you should modify the first if statement to make sure that the calculation code only runs when the operation is = to Insert. So change this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;if (eventObj.IsUndoRedo)&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;To this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;if (eventObj.IsUndoRedo || eventObj.Operation != &amp;quot;Insert&amp;quot;)&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Then if the operation is Delete (which is going to run when you clear the existing value in the cell, before you fill in a new value), you&amp;#39;ll just return and your caclulation code won&amp;#39;t run.&lt;/p&gt;
&lt;p&gt;Next, you&amp;#39;ll want to use eventObj.Site and relative XPath to get your node values, so that you have the values for the same row as the one with the changed field. For example, instead of this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;var plQtyPer = XDocument.DOM.selectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:tblDetailsInfo/@plQtyPer&amp;quot;);&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Try this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;var plQtyPer = eventObj.Site.selectSingleNode(&amp;quot;../@plQtyPer&amp;quot;);&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Since you are running you code when the plPartCost field changes, you&amp;#39;d reference that node simply as eventObj.Site, like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;var plPartCost = eventObj.Site;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Finally, I&amp;#39;m not sure why your code isn&amp;#39;t running every time the plPartCost field changes, my guess may be that the &amp;#39;handler&amp;#39; variable isn&amp;#39;t always what you think it is. Type &lt;strong&gt;debugger;&lt;/strong&gt; right above that variable so that you can try stepping through your code.&lt;/p&gt;</description></item><item><title>Re: The 2nd row of a repeating table does not calculate fields via code behind?</title><link>https://www.infopathdev.com:443/forums/thread/53789.aspx</link><pubDate>Fri, 16 Apr 2010 17:39:30 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:53789</guid><dc:creator>cdavis</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/53789.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=43&amp;PostID=53789</wfw:commentRss><description>&lt;p&gt;I am using JScript as my code behind.&lt;/p&gt;&lt;p&gt;When I tab from the Part Cost field it is set to fire the On After Change Event.&amp;nbsp; Which then calculates the Ext Cost field.&amp;nbsp; This works on the first row, but not the second (or more) row.&amp;nbsp; I have attached an image that shows the results.&amp;nbsp; The grey fields are calculated and the preceding field fires the On After Change Event.&lt;/p&gt;&lt;p&gt;I am not sure about absolute vs. relative.&amp;nbsp; I am assuming that I am using absolute.&lt;/p&gt;&lt;p&gt;EXAMPLE:&lt;/p&gt;&lt;p&gt;&amp;nbsp;function msoxd__tblDetailsInfo_plPartCost_attr::OnAfterChange(eventObj)&lt;br /&gt;{&lt;br /&gt;// Write code here to restore the global state.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (eventObj.IsUndoRedo)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// An undo or redo operation has occurred and the DOM is read-only.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;// A field change has occurred and the DOM is writable. Write code here to respond to the changes.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;handler = 1;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Calculate Extended Cost, 13.5% OH, and Duty Cost columns.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// CALC: Extended Cost Calculation&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var plQtyPer = XDocument.DOM.selectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:tblDetailsInfo/@plQtyPer&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var plScrapPct = XDocument.DOM.selectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:tblDetailsInfo/@plScrapPct&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var plPartCost = XDocument.DOM.selectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:tblDetailsInfo/@plPartCost&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var plExtCost = XDocument.DOM.selectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:tblDetailsInfo/@plExtCost&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Calculate the new value and set it to 4 decimal places.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var calcExtCost = (parseFloat(plPartCost.value * (plScrapPct.value * .01)) + parseFloat(plPartCost.value));&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;plExtCost.text = calcExtCost.toFixed(4);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// CALC: 13.5 OH&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var plOHPct = XDocument.DOM.selectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:tblDetailsInfo/@plOHPct&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var calcOH = (parseFloat(plExtCost.value) * .135);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;plOHPct.text = calcOH.toFixed(4);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// CALC: Duty Cost&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var plDutyCost = XDocument.DOM.selectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:tblDetailsInfo/@plDutyCost&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var plDutyPct = XDocument.DOM.selectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:tblDetailsInfo/@plDutyPct&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var calcDutyCost = (parseFloat(plDutyPct.value) * parseFloat(plExtCost.value));&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;plDutyCost.text = calcDutyCost.toFixed(4);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Set handler back to zero to prevent &amp;quot;infinite loop&amp;quot; error.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;handler = 0;&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks in advance for the help.&amp;nbsp; I have tried to run in debug and set stop points, but I haven&amp;#39;t seemed to be able to get it to work.&amp;nbsp; So I have put in XDocument.UI.Alert(field_name); in to test and then only pop once so I am assuming they are not firing the second time?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks! &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;img alt="" /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: The 2nd row of a repeating table does not calculate fields via code behind?</title><link>https://www.infopathdev.com:443/forums/thread/53779.aspx</link><pubDate>Fri, 16 Apr 2010 15:57:28 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:53779</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/53779.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=43&amp;PostID=53779</wfw:commentRss><description>&lt;p&gt;Hey, Chris:&lt;/p&gt;
&lt;p&gt;What is your code? What fields do you have Changed events on? How do you know the Changed events aren&amp;#39;t firing? If you&amp;#39;ve used absolute rather than relative XPath in your code, you may just be repeatedly recalculating your first row values, so it only looks like the events aren&amp;#39;t firing. Have you run your code in debug to see if the event fires or not?&lt;/p&gt;</description></item><item><title>The 2nd row of a repeating table does not calculate fields via code behind?</title><link>https://www.infopathdev.com:443/forums/thread/53771.aspx</link><pubDate>Fri, 16 Apr 2010 14:16:19 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:53771</guid><dc:creator>cdavis</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/53771.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=43&amp;PostID=53771</wfw:commentRss><description>&lt;p&gt;I am really liking InfoPath 2007.&amp;nbsp; However, I am still learning. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Another question... &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I have a repeating table that has multiple rows.&amp;nbsp; The user will insert the first row, fill out a couple of fields and then as they tab through the columns certain fields will be calculated via code behind.&amp;nbsp; However, when you do the same thing with row 2 (and beyond) the code behind calculated fields do not calculate (no code behind fires)?&lt;/p&gt;&lt;p&gt;&amp;nbsp;Any ideas?&amp;nbsp; I am at a loss.&amp;nbsp; It is probably something small, but I can see it or find it.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks,&lt;/p&gt;&lt;p&gt;Chris &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>