<?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>Select from secondary data source  - Object variable not set</title><link>https://www.infopathdev.com:443/forums/thread/20937.aspx</link><pubDate>Tue, 19 Jun 2007 13:04:06 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:20937</guid><dc:creator>NoCanDo</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/20937.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=20937</wfw:commentRss><description>&lt;p&gt;Hi I&amp;#39;m back again!&lt;/p&gt;&lt;p&gt;What I&amp;#39;m trying to do overall is select the lowest number (Text not integer) from a secondary source table where two other parameters are &amp;#39;true&amp;#39; and put that value in the Main data table. Example of the secondary data source is below:&lt;/p&gt;&lt;p&gt;Available table (all fields are text)&lt;br /&gt;Number&amp;nbsp;Site&amp;nbsp;Allocated&lt;br /&gt;300397&amp;nbsp;Sleaford&amp;nbsp;ALLOCATED&lt;br /&gt;300398&amp;nbsp;Sleaford&amp;nbsp;OPEN&lt;br /&gt;300399&amp;nbsp;Sleaford&amp;nbsp;OPEN&lt;br /&gt;300400&amp;nbsp;Fenton&amp;nbsp;ALLOCATED&lt;br /&gt;300401&amp;nbsp;Fenton&amp;nbsp;ALLOCATEDQ&lt;br /&gt;300402&amp;nbsp;Fenton&amp;nbsp;OPEN&lt;br /&gt;300403&amp;nbsp;Fenton&amp;nbsp;OPEN&lt;br /&gt;300404&amp;nbsp;Fenton&amp;nbsp;OPEN&lt;/p&gt;&lt;p&gt;At present, What I believe I am asking the code to do is to select the value from field &amp;#39;Number&amp;#39; in the Available table where the field Allocated=&amp;#39;ALLOCATEDQ&amp;#39; in the Available table and Site=&amp;#39;Fenton&amp;#39; in the Available table. (In effect, I want it to put 300401 into Non-Standard_Table/@AllocatedNumber).&amp;nbsp; (The next step is I want to be able to select the lowest number ie 300402 based on &amp;#39;OPEN&amp;#39; and &amp;#39;Fenton&amp;#39;.)&lt;/p&gt;&lt;p&gt;What happens is InfoPath returns: &amp;quot;Object variable not set&amp;quot;.&lt;/p&gt;&lt;p&gt;I cannot get past this aspect.&amp;nbsp; The problem occurs on the line:&lt;/p&gt;&lt;p&gt;strNode = Xdocument.dom.selectSingleNode(&amp;quot;//dfs:myFields/dfs:dataFields/d:Available_Table/Number[@Allocated=&amp;#39;ALLOCATEDQ&amp;#39; and @Site=&amp;#39;Fenton&amp;#39;]&amp;quot;)&lt;/p&gt;&lt;p&gt;All existing code associated with the button on the form is below.&lt;/p&gt;&lt;p&gt;I hope you can help as I&amp;#39;ve had a really really frustrating couple of days working on this.&lt;/p&gt;&lt;p&gt;Please help - the NoCanDo-er!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;lt;namespacesDefinition&amp;gt;&lt;br /&gt;XDocument.DOM.setProperty &amp;quot;SelectionNamespaces&amp;quot;, &amp;quot;xmlns:xsi=&amp;quot;&amp;quot;&lt;a href="http://www.w3.org/2001/XMLSchema-instance"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;&amp;quot;&amp;quot; xmlns:q=&amp;quot;&amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields"&gt;http://schemas.microsoft.com/office/infopath/2003/ado/queryFields&lt;/a&gt;&amp;quot;&amp;quot; xmlns:d=&amp;quot;&amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"&gt;http://schemas.microsoft.com/office/infopath/2003/ado/dataFields&lt;/a&gt;&amp;quot;&amp;quot; xmlns:dfs=&amp;quot;&amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"&gt;http://schemas.microsoft.com/office/infopath/2003/dataFormSolution&lt;/a&gt;&amp;quot;&amp;quot; xmlns:my=&amp;quot;&amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-09T12:56:16"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-09T12:56:16&lt;/a&gt;&amp;quot;&amp;quot; xmlns:xd=&amp;quot;&amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003"&gt;http://schemas.microsoft.com/office/infopath/2003&lt;/a&gt;&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;&amp;#39;&amp;lt;/namespacesDefinition&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Sub CTRL401_4_OnClick(eventObj)&lt;/p&gt;&lt;p&gt;&amp;#39; Code for &amp;#39;Start Number Allocation Process&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;#39;VARIABLES&lt;br /&gt;&amp;#39;SITEID used to differentiate between sites without naming issues&lt;br /&gt;Dim strSITE&lt;br /&gt;Dim strSITEID&lt;br /&gt;Dim strNEWNUM&lt;br /&gt;Dim strNAME&lt;br /&gt;Dim strEXISTS&lt;br /&gt;Dim strNONSTD&lt;br /&gt;Dim strNUMBER&lt;br /&gt;strEXISTS=1&lt;/p&gt;&lt;p&gt;&amp;#39;INFOPATH READ INFO from Non-Standard table&lt;br /&gt;strSITE = Xdocument.dom.selectSingleNode(&amp;quot;//dfs:myFields/dfs:dataFields/d:Non-Standard_Table/@SiteName&amp;quot;).text&lt;br /&gt;strSITEID = Xdocument.dom.selectSingleNode(&amp;quot;//dfs:myFields/dfs:dataFields/d:Non-Standard_Table/@SiteID&amp;quot;).text &lt;br /&gt;strNAME = Xdocument.dom.selectSingleNode(&amp;quot;//dfs:myFields/dfs:dataFields/d:Non-Standard_Table/@GeneralName&amp;quot;).text&lt;br /&gt;strNONSTD = Xdocument.dom.selectSingleNode(&amp;quot;//dfs:myFields/dfs:dataFields/d:Non-Standard_Table/@NonStdReq&amp;quot;).text&lt;/p&gt;&lt;p&gt;dim strVal&lt;br /&gt;dim strNode&lt;/p&gt;&lt;p&gt;strVal = -1&lt;br /&gt;&lt;strong&gt;strNode = Xdocument.dom.selectSingleNode(&amp;quot;//dfs:myFields/dfs:dataFields/d:Available_Table/Number[@Allocated=&amp;#39;ALLOCATEDQ&amp;#39; and @Site=&amp;#39;Fenton&amp;#39;]&amp;quot;)&lt;/strong&gt;&lt;br /&gt;if( [strNode != &amp;quot;&amp;quot;] )then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strNode = strVal.text&amp;nbsp; &amp;#39;try strNode = strVal&lt;br /&gt;end if&lt;/p&gt;&lt;p&gt;sql = &amp;quot;UPDATE Available SET Allocated = (&amp;#39;&amp;quot;&amp;amp; strNAME &amp;amp; &amp;quot;&amp;#39;) WHERE Number = (&amp;#39;&amp;quot;&amp;amp; strNEWNUM &amp;amp; &amp;quot;&amp;#39;)&amp;quot;&lt;br /&gt;&amp;nbsp;set rs = db.Execute(sql)&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;#39;WRITE TO INFOPATH&lt;br /&gt;&amp;nbsp;Xdocument.dom.selectSingleNode(&amp;quot;//dfs:myFields/dfs:dataFields/d:Non-Standard_Table/@AllocatedNumber&amp;quot;).text=strNEWNUM&lt;br /&gt;&amp;nbsp;&lt;br /&gt;End sub&lt;/p&gt;</description></item></channel></rss>