<?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: Setting Field Values in a New Row of a Repeating Table</title><link>https://www.infopathdev.com:443/forums/thread/72001.aspx</link><pubDate>Sun, 13 Nov 2011 15:04:36 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:72001</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/72001.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=72001</wfw:commentRss><description>&lt;p&gt;It&amp;#39;s not really a glitch at all.&amp;nbsp; The xsi:nil attribute has to be there when the field is created in order for it to be valid.&amp;nbsp; It&amp;#39;s a schema violation for a numeric field to be blank unless it has an xsi:nil attribute.&amp;nbsp; But it&amp;#39;s also a schema violation for a field to have a value and an xsi:nil attribute at the same time, hence that error.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;At any rate, we discourage the practice of writing custom code for InfoPath forms, and I think you&amp;#39;re starting to find out why.&amp;nbsp; If you&amp;#39;d like an easier time, try out &lt;a href="http://www.qdabra.com/en/products/qRules_overview.aspx"&gt;qRules&lt;/a&gt;.&amp;nbsp; It can do almost everything people want InfoPath code to do, and won&amp;#39;t require you to write a single line of code.&lt;/p&gt;</description></item><item><title>Re: Setting Field Values in a New Row of a Repeating Table</title><link>https://www.infopathdev.com:443/forums/thread/72000.aspx</link><pubDate>Sun, 13 Nov 2011 13:28:01 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:72000</guid><dc:creator>JAWSURGEON</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/72000.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=72000</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;You are correct.&lt;/p&gt;&lt;p&gt;Rxfield = RxRow.SelectSingleNode(&amp;quot;./my:cboRXQuantity&amp;quot;, NamespaceManager)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rxfield.MoveToAttribute(&amp;quot;nil&amp;quot;, &amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rxfield.DeleteSelf()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rxfield.SetValue(&amp;quot;20&amp;quot;)&lt;/p&gt;&lt;p&gt;...that fixed the issue.( I can&amp;#39;t believe MSFT let this kind of glitch slide by in infopath..this really shouldn&amp;#39;t require all this code to set a value).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks&amp;nbsp;&lt;/p&gt;&lt;p&gt;Adam &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Setting Field Values in a New Row of a Repeating Table</title><link>https://www.infopathdev.com:443/forums/thread/71999.aspx</link><pubDate>Sun, 13 Nov 2011 04:11:43 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:71999</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/71999.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=71999</wfw:commentRss><description>&lt;p&gt;If changing the datatype from integer to text fixed the issue, then most likely the problem was that there was an xsi:nil attribute on the field that needed to be removed first.&amp;nbsp; Searching this forum for xsi:nil will get you a lot of info on that.&amp;nbsp; The only thing strange about that is that I wouldn&amp;#39;t expect that to cause a &amp;quot;reference is invalid&amp;quot; error.&amp;nbsp; Is that really what the error said?&lt;/p&gt;</description></item><item><title>Re: Setting Field Values in a New Row of a Repeating Table</title><link>https://www.infopathdev.com:443/forums/thread/71998.aspx</link><pubDate>Sat, 12 Nov 2011 15:26:48 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:71998</guid><dc:creator>JAWSURGEON</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/71998.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=71998</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;So I solved the problem (partly)&lt;/p&gt;&lt;p&gt;the Combobox was set to type &amp;quot;integer&amp;quot; rather than &amp;quot;text&amp;quot;.&lt;/p&gt;&lt;p&gt;Once I changed that all is good.&lt;/p&gt;&lt;p&gt;Now my next question is...can you set the value of a type combbox where input is restricted to &amp;#39;integer&amp;#39; values.&lt;/p&gt;&lt;p&gt;the &amp;#39;setvalue&amp;#39; method only accepts strings.&lt;/p&gt;&lt;p&gt;There must be a logical way to set the value of a field type integer.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks in advance .... &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Setting Field Values in a New Row of a Repeating Table</title><link>https://www.infopathdev.com:443/forums/thread/71997.aspx</link><pubDate>Sat, 12 Nov 2011 14:56:45 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:71997</guid><dc:creator>JAWSURGEON</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/71997.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=71997</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Thanks for the reply and suggestion&lt;/p&gt;&lt;p&gt;the spelling/case issue you pointed out is NOT the source of the problem.&lt;/p&gt;&lt;p&gt;&amp;nbsp;-- &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Setting Field Values in a New Row of a Repeating Table</title><link>https://www.infopathdev.com:443/forums/thread/71996.aspx</link><pubDate>Sat, 12 Nov 2011 11:09:26 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:71996</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/71996.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=71996</wfw:commentRss><description>&lt;p&gt;First, this is not related to your issue, but this is completely unnecessary:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;create a navigator to iterate through the table&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim RxRows As XPathNodeIterator = RXnav.Select(&amp;quot;/my:myFields/my:Exam/my:grpRXHeader/my:grpRX&amp;quot;, NamespaceManager)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;get a count of rows&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; While RxRows.MoveNext()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i + 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End While&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Just use [last()] in your XPath instead of all that.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;As to your issue, there are two possible reasons you would be getting a null reference exception: either the field is missing for some reason, or you spelled its name wrong.&amp;nbsp; The latter is far more likely in this case and since you spelled it &lt;strong&gt;cboRxquantity&lt;/strong&gt; in your comment, and then &lt;strong&gt;cboRXQuantity&lt;/strong&gt; in the code, I&amp;#39;m going to guess that&amp;#39;s almost definitely the issue.&lt;/p&gt;</description></item><item><title>Setting Field Values in a New Row of a Repeating Table</title><link>https://www.infopathdev.com:443/forums/thread/71994.aspx</link><pubDate>Sat, 12 Nov 2011 02:37:27 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:71994</guid><dc:creator>JAWSURGEON</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/71994.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=71994</wfw:commentRss><description>&lt;p&gt;Purpose: User clicks Button &amp;quot;Augmentin&amp;quot;; code then populates 4 fields in a new row of repeating table.&lt;/p&gt;&lt;p&gt;Paradigm: 1. Add a new row.; then count the number of rows and position navigator on last (new) row. Then add field values&lt;/p&gt;&lt;p&gt;Here is the code:&lt;/p&gt;&lt;p&gt;Public Sub btnAugmentin_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Write your code here.&lt;/p&gt;&lt;p&gt;&amp;#39;add a new row....&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CurrentView.ExecuteAction(ActionType.XCollectionInsert, &amp;quot;group96_294&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&amp;nbsp;&amp;nbsp; Dim i As Integer&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim RXnav As XPathNavigator = MainDataSource.CreateNavigator()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;create a navigator to iterate through the table&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim RxRows As XPathNodeIterator = RXnav.Select(&amp;quot;/my:myFields/my:Exam/my:grpRXHeader/my:grpRX&amp;quot;, NamespaceManager)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;get a count of rows&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; While RxRows.MoveNext()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i + 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End While&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&amp;nbsp;&amp;nbsp; &amp;#39;position on the last row of the table&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim RxRow As XPathNavigator = RXnav.SelectSingleNode(&amp;quot;/my:myFields/my:Exam/my:grpRXHeader/my:grpRX[ &amp;quot; &amp;amp; i.ToString &amp;amp; &amp;quot;]&amp;quot;, NamespaceManager)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;get a reference to the field &amp;quot;cboDrug&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim Rxfield As XPathNavigator = RxRow.SelectSingleNode(&amp;quot;./my:cboDrug&amp;quot;, NamespaceManager)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;set the value of the field&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rxfield.SetValue(&amp;quot;Augmentin&amp;quot;)&lt;/p&gt;&lt;p&gt;&amp;#39;..............so far so good..........................&lt;br /&gt;&amp;#39;now set the value of field &amp;quot;cboRxquantity&amp;quot; to 20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rxfield = RxRow.SelectSingleNode(&amp;quot;./my:cboRXQuantity&amp;quot;, NamespaceManager)&lt;/p&gt;&lt;p&gt;&amp;#39;code fails at next line....reference is invalid&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rxfield.SetValue(&amp;quot;20&amp;quot;) &lt;/p&gt;&lt;p&gt;Issues are: how to all the other fields on the new row&lt;/p&gt;&lt;p&gt;other issue: how to use the&amp;nbsp; &amp;quot;addchild&amp;quot; method to add a row rather than the XcollectionInsert&lt;/p&gt;&lt;p&gt;Thanks in advance to anyone who answers!!&lt;/p&gt;&lt;p&gt;Adam &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>