<?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>Data Connections</title><link>https://www.infopathdev.com:443/forums/44.aspx</link><description> </description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Query Button -&gt; Rules &amp; Dif. Views</title><link>https://www.infopathdev.com:443/forums/thread/66526.aspx</link><pubDate>Fri, 13 May 2011 16:59:34 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:66526</guid><dc:creator>morphguy112</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/66526.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=44&amp;PostID=66526</wfw:commentRss><description>&lt;p&gt;Thanks for the quick response guys, I was actually able to figure it out after a few hours with your help!
&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;One last thing, 
I used the Clear Button Code from:
http://www.bizsupportonline.net/blog/2009/08/clear-reset-fields-infopath-3-lines-code/
&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
So my &amp;quot;Go Back&amp;quot; button will clear the form and bring you to the &amp;quot;Default View&amp;quot;
Code for button:
MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/dfs:myFields/dfs:dataFields/d:My_Data&amp;quot;, NamespaceManager).ReplaceSelf(initialData)
&lt;br /&gt;&lt;br /&gt;
This works great if my query finds a result and fills in the fields, but if nothing is found and I hit back, this error pops up:
&amp;quot;System.NullReferenceException
Object reference not set to an instance of an object.
   at Template1.FormCode.CTRL1_21_Clicked(Object sender, ClickedEventArgs e)
   at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
   at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)&amp;quot;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;
But if I have a view where it doesn&amp;#39;t query at first, and I don&amp;#39;t fill out any of the fields, then the &amp;quot;Go Back&amp;quot; button works just fine, but that view doesn&amp;#39;t have a repeating table ( Master &amp;amp; Detail View)   hmmm....
&lt;/p&gt;&lt;br /&gt;&lt;p&gt;
Would an IF function prevent this from happening?  I don&amp;#39;t even know where to start on how to determine if the fields are blank because of no match with the search.
&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
Any help would definitely be greatly appreciated!
Thanks!!</description></item><item><title>Re: Query Button -&gt; Rules &amp; Dif. Views</title><link>https://www.infopathdev.com:443/forums/thread/66503.aspx</link><pubDate>Thu, 12 May 2011 21:09:25 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:66503</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/66503.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=44&amp;PostID=66503</wfw:commentRss><description>&lt;p&gt;Hi -- So &amp;quot;variable a&amp;quot; is a field in the main data source of the form? For testing purposes, try adding another button -- have it run your query then display a message box with the value of that field, so you feel confident that you know what the value is before setting conditions that involve it. And yes, you can have a button that runs a query then set a field&amp;#39;s value.....&lt;/p&gt;</description></item><item><title>Re: Query Button -&gt; Rules &amp; Dif. Views</title><link>https://www.infopathdev.com:443/forums/thread/66495.aspx</link><pubDate>Thu, 12 May 2011 16:53:25 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:66495</guid><dc:creator>morphguy112</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/66495.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=44&amp;PostID=66495</wfw:commentRss><description>I did that but still nothing.
Are buttons able to Query the data and then set a data field?

I don&amp;#39;t think that Variable A is changing, the rules aren&amp;#39;t recognizing the conditions I am setting - so it isn&amp;#39;t switching views.

My brain is hurting :)</description></item><item><title>Re: Query Button -&gt; Rules &amp; Dif. Views</title><link>https://www.infopathdev.com:443/forums/thread/66478.aspx</link><pubDate>Thu, 12 May 2011 06:21:39 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:66478</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/66478.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=44&amp;PostID=66478</wfw:commentRss><description>&lt;p&gt;Why not just leave the condition blank for Rule 4? Then, it will always fire the action. :) &lt;/p&gt;</description></item><item><title>Query Button -&gt; Rules &amp; Dif. Views</title><link>https://www.infopathdev.com:443/forums/thread/66472.aspx</link><pubDate>Thu, 12 May 2011 00:45:54 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:66472</guid><dc:creator>morphguy112</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/66472.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=44&amp;PostID=66472</wfw:commentRss><description>&lt;p&gt;Hey guys,&lt;/p&gt;&lt;p&gt;First Post, definitely glad to be a part of the forum!&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I&amp;#39;ve got most of my form setup, there just one thing I&amp;#39;d like to try and do.&amp;nbsp; I&amp;#39;ve spent a few hours trying to figure this out online and this forum with no luck, so I&amp;#39;m wondering if this is even possible.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I also apologize if I posted this in the wrong section,&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I have an Access Database attached to my form and I&amp;#39;m trying to:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;One Query Field: Record #&lt;br /&gt;&lt;/p&gt;&lt;p&gt;One Run Query Button w/:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Rule 1: IF&amp;nbsp;&amp;nbsp; datafield: Variable A =1&amp;nbsp; THEN SwitchView 2&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Rule 2: IF&amp;nbsp;&amp;nbsp; datafield: Variable A=0 &amp;nbsp; THEN SwitchView 3&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Rule 3: IF query comes up with no resules&amp;nbsp;&amp;nbsp; THEN&amp;nbsp;&amp;nbsp; No Record Found PopUp, Reset Form (View 1)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I guess I could include another Query Field for Variable A, but I&amp;#39;d 
really want to try and get this to work.&amp;nbsp; One less step for users.&lt;/p&gt;&lt;p&gt;Any help would greatly, greatly appreciated!!&amp;nbsp; I have been trying with Rules, but no luck. I&amp;#39;m also setup with VB.&lt;/p&gt;&lt;p&gt;I&amp;#39;ll also post up my Rules when I get back at work tomorrow morning if that&amp;#39;ll help.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I remember that I tried this, but didn&amp;#39;t work:&lt;/p&gt;&lt;p&gt;Rule 1: Run Query to Database&lt;/p&gt;&lt;p&gt;Rule 2: Condition: if DataField Variable A=1&amp;nbsp;&amp;nbsp; ()&amp;nbsp; Action: Switch view2&amp;nbsp;&amp;nbsp; ( End rules box checked)&lt;/p&gt;&lt;p&gt;Rule 3: Condition&amp;nbsp; if DataField Variable A=0 () Action: Switch View 3 (End Rules Box checked)&lt;/p&gt;&lt;p&gt;Rule 4: Condition if DataField Variable IS BLANK &amp;nbsp;&amp;nbsp; Action: Popup Message &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks guys!! &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>