<?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: What is the Visual Basic code for setting a field value from a secondary data source?</title><link>https://www.infopathdev.com:443/forums/thread/58746.aspx</link><pubDate>Tue, 07 Sep 2010 06:24:35 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:58746</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/58746.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=58746</wfw:commentRss><description>&lt;p&gt;What I meant was something like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt;&lt;font size="2"&gt; mainNavigator &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; = Me.CreateNavigator()&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;Dim&lt;/font&gt;&lt;font size="2"&gt; codeInfoNavigator &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; = Me.DataSources(&lt;font color="#800000"&gt;&amp;quot;Get_Existing_Engagement_Code_info&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;).CreateNavigator().SelectSingleNode(&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/dfs:myFields/dfs:dataFields/ns1:GetColumnsXMLStrQueryResponse/ns1:GetColumnsXMLStrQueryResult/Rows/row&amp;quot;&lt;/font&gt;&lt;/font&gt;)&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;once you have that, the code is more concise and efficient.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;mainNavigator.SelectSingleNode(&lt;font color="#800000"&gt;&amp;quot;/my:myFields/my:Date_Letter&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.NamespaceManager).SetValue(codeInfoNavigator.SelectSingleNode(&amp;quot;BudgetCost&amp;quot;).Value)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I think there&amp;#39;s probably very little difference in speed versus setting a field value in code vs. in rules, but at Qdabra it&amp;#39;s our policy to use rules&amp;nbsp;rather than&amp;nbsp;code whenever possible because it is more straightforward,&amp;nbsp;makes the form easier to maintain, and doesn&amp;#39;t require coding experience to make modifications.&lt;/p&gt;</description></item><item><title>Re: What is the Visual Basic code for setting a field value from a secondary data source?</title><link>https://www.infopathdev.com:443/forums/thread/58744.aspx</link><pubDate>Tue, 07 Sep 2010 02:47:20 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:58744</guid><dc:creator>ZhenYuan</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/58744.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=58744</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hi Potemkine,&lt;/p&gt;
&lt;p&gt;Nice to hear from you again. Ok, noted about the rules vs code part. I&amp;#39;m still using your code to refresh this new form though :)&lt;/p&gt;
&lt;p&gt;I was thinking of using code because my form has multiple sections and nested sections and thus using rules can sometimes take quite a lot of mouse clicks. Was just trying to find out if it can be done via code which allows me to copy and paste xpaths which I thought can save abit of form development time.&lt;/p&gt;</description></item><item><title>Re: What is the Visual Basic code for setting a field value from a secondary data source?</title><link>https://www.infopathdev.com:443/forums/thread/58743.aspx</link><pubDate>Tue, 07 Sep 2010 02:25:41 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:58743</guid><dc:creator>Potemkine</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/58743.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=58743</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/infopathdev/images/icon-quote.gif"&gt; &lt;strong&gt;Jimmy:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;But what makes you think that this would be faster than using rules?&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;I think it was my fault. I say that on a context that he have a lot of field to reinitialize, so instead of use a rules for each fiel.d I suggest to use code to replace the parent node with a empty reference node in this case using code is faster but if you just want to asign a value to a field it&amp;#39;s the same.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: What is the Visual Basic code for setting a field value from a secondary data source?</title><link>https://www.infopathdev.com:443/forums/thread/58742.aspx</link><pubDate>Tue, 07 Sep 2010 02:15:18 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:58742</guid><dc:creator>ZhenYuan</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/58742.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=58742</wfw:commentRss><description>&lt;p&gt;Hi Jimmy,&lt;/p&gt;
&lt;p&gt;I decided to just use rules :) but for knowledge sake, I&amp;#39;ll still like to know how I can go about this in code?&lt;/p&gt;
&lt;p&gt;Is it more efficient to use rules instead of code?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;</description></item><item><title>Re: What is the Visual Basic code for setting a field value from a secondary data source?</title><link>https://www.infopathdev.com:443/forums/thread/58740.aspx</link><pubDate>Tue, 07 Sep 2010 01:38:40 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:58740</guid><dc:creator>ZhenYuan</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/58740.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=58740</wfw:commentRss><description>&lt;p&gt;Hi Jimmy, &lt;/p&gt;
&lt;p&gt;Thanks for your help again. When you say variabled, do you mean:&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Dim&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; oItem &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Dim&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; oSecData &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;String&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;oItem = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/my:myFields/my:Date_Letter&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.NamespaceManager)&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;oSecData = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.DataSources(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;Get_Existing_Engagement_Code_info&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/dfs:myFields/dfs:dataFields/ns1:GetColumnsXMLStrQueryResponse/ns1:GetColumnsXMLStrQueryResult/Rows/row/BudgetCost&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.NamespaceManager).Value&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;oItem.SetValue(oSecData)&lt;/p&gt;
&lt;p&gt;-------------------------------------&lt;/p&gt;
&lt;p&gt;And then reusing the variables oItem and oSecData for the other fields? But during each declaration of variable values like &amp;quot;oItem = &lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/my:myFields/my:Date_Letter&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.NamespaceManager)&amp;quot;, won&amp;#39;t the Namespacemanagers be created as well? Unless I am coding it inefficiently.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Actually, I suspect it takes the same amount of time as compared to using rules. Just that it is faster to set all your values using code rather than rules (when you have many fields). Saves time for the form creator.&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: What is the Visual Basic code for setting a field value from a secondary data source?</title><link>https://www.infopathdev.com:443/forums/thread/58718.aspx</link><pubDate>Mon, 06 Sep 2010 13:07:32 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:58718</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/58718.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=58718</wfw:commentRss><description>&lt;p&gt;Me&lt;font size="2"&gt;.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/my:myFields/my:Date_Letter&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.NamespaceManager).SetValue(&lt;/font&gt;Me.DataSources(&amp;quot;&lt;strong&gt;&lt;em&gt;DataSourceName&lt;/em&gt;&lt;/strong&gt;&amp;quot;).CreateNavigator().SelectSingleNode(&amp;quot;&lt;strong&gt;&lt;em&gt;xpath&lt;/em&gt;&lt;/strong&gt;&amp;quot;, Me.NamespaceManager).Value&lt;font size="2"&gt;)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;To put it simply.&amp;nbsp;Naturally, the ideal would be to use variables to store the two namespace managers so you don&amp;#39;t need to keep creating them.&lt;/p&gt;
&lt;p&gt;But what makes you think that this would be faster than using rules?&lt;/p&gt;</description></item><item><title>Re: What is the Visual Basic code for setting a field value from a secondary data source?</title><link>https://www.infopathdev.com:443/forums/thread/58717.aspx</link><pubDate>Mon, 06 Sep 2010 11:55:47 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:58717</guid><dc:creator>ZhenYuan</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/58717.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=58717</wfw:commentRss><description>&lt;p&gt;To add on, what I&amp;#39;m trying to do is something like:&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/my:myFields/my:Date_Letter&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.NamespaceManager).SetValue(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;abcd&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Except that SetValue is not applicable for xpath input. It only takes string values. I hope to be able to replace &amp;quot;abcd&amp;quot; with a xpath to my secondary data.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Thanks!&lt;/p&gt;&lt;/font&gt;</description></item><item><title>What is the Visual Basic code for setting a field value from a secondary data source?</title><link>https://www.infopathdev.com:443/forums/thread/58708.aspx</link><pubDate>Mon, 06 Sep 2010 09:03:01 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:58708</guid><dc:creator>ZhenYuan</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/58708.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=58708</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I understand that rules can be set to populate fields using data retrieved from a secondary data source. I&amp;#39;m just wondering if this can be done via Visual Basic code?&lt;/p&gt;
&lt;p&gt;Reason is because I kind of have alot of fields and using code might be faster to populate my form?&lt;/p&gt;
&lt;p&gt;The replaceself function can be used to replace nodes but is there code to replace fields themselves?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;</description></item></channel></rss>