<?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>Newbie Questions</title><link>https://www.infopathdev.com:443/forums/39.aspx</link><description>New to InfoPath? Search to see if your question has already been answered. If it has not, then ask it here or the appropriate topic forum.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Programmatically add an instance of a Repeating Section</title><link>https://www.infopathdev.com:443/forums/thread/61614.aspx</link><pubDate>Tue, 23 Nov 2010 12:28:51 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:61614</guid><dc:creator>greenawayr</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/61614.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=61614</wfw:commentRss><description>&lt;p&gt;I found this thread, which sort of helps, but I keep getting NullReferenceExceptions and I think I know why, but am unsure how to overcome it!&lt;/p&gt;&lt;p&gt;http://www.infopathdev.com/forums/t/12394.aspx?PageIndex=1 &lt;br /&gt;&lt;/p&gt;&lt;p&gt;My Datasource is structured as shown in the image attached. As you can see I have a group called (Choice), I presume this is a group that occurs due to the form being based on a webservice. However, if I right-click on it I cannot copy X-Path. Is this the cause for me not being able to write to any of the fields within the Repeating sections that exist within this group? If I copy the XPath for the group SelfGeneratedCases (which is the group that I want to exist when the ClientType dropdown is set to a certain value), then this is what I get &lt;/p&gt;&lt;p&gt;/dfs:myFields/dfs:dataFields/tns:GetFormDatasetResponse/tns:GetFormDatasetResult/ns1:dsForms/ns1:SelfGeneratedCases&lt;/p&gt;&lt;p&gt;However, if I try to add this is any piece of code, then when I debug I get a NullReferenceException.&lt;/p&gt;&lt;p&gt;Any help on overcoming this is most appreciated.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description></item><item><title>Programmatically add an instance of a Repeating Section</title><link>https://www.infopathdev.com:443/forums/thread/61597.aspx</link><pubDate>Mon, 22 Nov 2010 17:36:14 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:61597</guid><dc:creator>greenawayr</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/61597.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=61597</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;I have a browser enabled form template based on a webservice that is connected to a SQL database.&lt;/p&gt;&lt;p&gt;On my form I have a simple dropdown box, which when a certain value is selected requires a new part of the form to appear and be filled in.&lt;/p&gt;&lt;p&gt;The easy way to do this seemed to be Conditional Formatting, however, because the form is connected to database via a webservice, the table that this part of the form relates to has no new row that relates to the rest of the form, therefore the section will not appear automatically. All I get is the link to &amp;quot;Click here to insert&amp;quot;. This is the same for all the sections in our form, but for the sections that have been required to display at Form Load, we have added SQL triggers that inject the new row into the correct table and the form automatically displays the section with the Default Values entered in the table by SQL.&lt;/p&gt;&lt;p&gt;Ideally I&amp;#39;d simply like to have a rule that when &amp;quot;ClientType&amp;quot; has a certain value selected, the new section appears all on it&amp;#39;s own. Currently the link simply appears and disappears with the conditional formatting.&lt;/p&gt;&lt;p&gt;Is there a way to programmatically add the section as if someone had just clicked the &amp;quot;Click here to insert&amp;quot; link? Failing this, is there a way to force a value into a field, so that when the Client Type is selected the section appears automatically?&lt;/p&gt;&lt;p&gt;I have been looking at this approach which gave me this code&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Public Sub TempleType_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)&lt;br /&gt;&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 ClientType As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/tns:GetFormDatasetResponse/tns:GetFormDatasetResult/ns1:dsForms/ns1:Clients/ns1:TempleType&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; Dim Username As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/dfs:myFields/dfs:queryFields/tns:GetFormDataset/tns:pUserLoginId&amp;quot;, NamespaceManager)&lt;br /&gt;&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; Move to the root element of the document&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 root As XPathNavigator = Me.MainDataSource.CreateNavigator()&lt;br /&gt;&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; root.MoveToFollowing(XPathNodeType.Element)&lt;br /&gt;&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 an XPathNavigator pointing to the parent node where the repeating elements will be added&lt;br /&gt;&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 sectionNode As XPathNavigator = root.SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/tns:GetFormDatasetResponse/tns:GetFormDatasetResult/ns1:dsForms/ns1:SelfGeneratedCases&amp;quot;, Me.NamespaceManager)&lt;br /&gt;&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 ns As String = sectionNode.NamespaceURI&lt;br /&gt;&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; Add the XML tree for the child element&lt;br /&gt;&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; Using writer As XmlWriter = sectionNode.AppendChild()&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; writer.WriteStartElement(&amp;quot;my&amp;quot;, &amp;quot;SelfGeneratedCases&amp;quot;, ns)&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; writer.WriteElementString(&amp;quot;my&amp;quot;, &amp;quot;ChangeBy&amp;quot;, ns, Username.Value)&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; writer.WriteEndElement()&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 Using&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;But currently I am getting a NullReferenceException on this line&lt;/p&gt;&lt;p&gt;Dim ns As String = sectionNode.NamespaceURI &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Any help anyone could give me on this is hugely appreciated as it&amp;#39;s pretty urgent.&lt;/p&gt;&lt;p&gt;Thanks &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>