Query Button -> Rules & Dif. Views - InfoPath Dev
in

InfoPath Dev

Query Button -> Rules & Dif. Views

Last post 05-13-2011 09:59 AM by morphguy112. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-11-2011 05:45 PM

    Query Button -> Rules & Dif. Views

    Hey guys,

    First Post, definitely glad to be a part of the forum!

    I've got most of my form setup, there just one thing I'd like to try and do.  I've spent a few hours trying to figure this out online and this forum with no luck, so I'm wondering if this is even possible.

    I also apologize if I posted this in the wrong section,

     

    I have an Access Database attached to my form and I'm trying to:

    One Query Field: Record #

    One Run Query Button w/:

        -Rule 1: IF   datafield: Variable A =1  THEN SwitchView 2

        -Rule 2: IF   datafield: Variable A=0   THEN SwitchView 3

        -Rule 3: IF query comes up with no resules   THEN   No Record Found PopUp, Reset Form (View 1)

     

    I guess I could include another Query Field for Variable A, but I'd really want to try and get this to work.  One less step for users.

    Any help would greatly, greatly appreciated!!  I have been trying with Rules, but no luck. I'm also setup with VB.

    I'll also post up my Rules when I get back at work tomorrow morning if that'll help.

     

    I remember that I tried this, but didn't work:

    Rule 1: Run Query to Database

    Rule 2: Condition: if DataField Variable A=1   ()  Action: Switch view2   ( End rules box checked)

    Rule 3: Condition  if DataField Variable A=0 () Action: Switch View 3 (End Rules Box checked)

    Rule 4: Condition if DataField Variable IS BLANK    Action: Popup Message

     

    Thanks guys!!

     

  • 05-11-2011 11:21 PM In reply to

    Re: Query Button -> Rules & Dif. Views

    Why not just leave the condition blank for Rule 4? Then, it will always fire the action. :)

    Patrick Halstead
    Project Manager at Qdabra
  • 05-12-2011 09:53 AM In reply to

    Re: Query Button -> Rules & Dif. Views

    I did that but still nothing. Are buttons able to Query the data and then set a data field? I don't think that Variable A is changing, the rules aren't recognizing the conditions I am setting - so it isn't switching views. My brain is hurting :)
  • 05-12-2011 02:09 PM In reply to

    Re: Query Button -> Rules & Dif. Views

    Hi -- So "variable a" 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's value.....

    Hilary Stoupa

  • 05-13-2011 09:59 AM In reply to

    Re: Query Button -> Rules & Dif. Views

    Thanks for the quick response guys, I was actually able to figure it out after a few hours with your help!

    One last thing, I used the Clear Button Code from: http://www.bizsupportonline.net/blog/2009/08/clear-reset-fields-infopath-3-lines-code/


    So my "Go Back" button will clear the form and bring you to the "Default View" Code for button: MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:My_Data", NamespaceManager).ReplaceSelf(initialData)

    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: "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)"



    But if I have a view where it doesn't query at first, and I don't fill out any of the fields, then the "Go Back" button works just fine, but that view doesn't have a repeating table ( Master & Detail View) hmmm....


    Would an IF function prevent this from happening? I don't even know where to start on how to determine if the fields are blank because of no match with the search.

    Any help would definitely be greatly appreciated! Thanks!!
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.