Filling Option Buttons from a data source? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Filling Option Buttons from a data source?

Last post 09-16-2011 10:57 PM by Skarn. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 09-06-2011 02:49 PM

    • Jtcom
    • Top 500 Contributor
    • Joined on 06-16-2011
    • Posts 34

    Filling Option Buttons from a data source?

    After much help from these forums I am not quite the newbie I was in my first post here, but I am still trying to figure out one hopefully basic function in InfoPath.  Now using DBXL’s data query tool I am building an InfoPath to pull SQL data, while at the same time having to match a paper copy of the document.  The original uses what are basically option buttons, and I have heard said that it is possible to auto fill option buttons from a data source, but I am not having much luck getting this working smoothly.  My current test has data pulled from SQL that is a number, 1 through 10, and then I set up option buttons with rules to set their value based on a textbox the number is pulled into elsewhere on the form.  The problems, I have to have the number appearing on the form in a box to pull the info for the rules, which I would rather avoid, and also the option buttons are not auto filling unless the user tries to click on one of them after the query has been run, at which point the selection snaps to the correct option button, and does not allow change untill the next query is run.

    My method seems very clunky and my hope is someone can point me to a much better way of doing this.   I suspect there is some way to use rules to do this better, but my current knowledge of rules does not point me in the direction of any rule option to use. 

     

  • 09-07-2011 05:26 AM In reply to

    Re: Filling Option Buttons from a data source?

    Hi,

    This should be fairly easy. If the data connection is running on form load, then you'll need an action after it. The new action will set the value of the field for the option buttons.

    As far as the extra field, you shouldn't really need that. Even if you need the extra field in the schema, you wouldn't need to display it in the canvas.

    I'm attaching a sample form. On load there is a rule that sets the value of the option button. In your scenario, that value would be coming from a secondary data source. Sorry that it is so simple; let me know if I oversimplified the scenario.

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 09-07-2011 07:23 AM In reply to

    • Jtcom
    • Top 500 Contributor
    • Joined on 06-16-2011
    • Posts 34

    Re: Filling Option Buttons from a data source?

    What I was trying to do in this form is acctually create a dynamic query, rather than a static one.  So the user puts in a id number in the query box, and all the data populates based on that id.  So I guess what I need would be some way to make the option button refreash after each query so that the user does not need to click on one of the buttons to force it to switch to the corect option button.  From what I see I think my rule is fairly similure to your example, except it is not set to run on load, but rather after a query is run based on a value generated.  Would there be any tricks in this situation beyond the type of rule in your example?

  • 09-08-2011 10:51 AM In reply to

    • Jtcom
    • Top 500 Contributor
    • Joined on 06-16-2011
    • Posts 34

    Re: Filling Option Buttons from a data source?

    Sorry, I think I oversimplified my description here so let me try to provide better details.  As I said I am pull data from the SQL database as a secondary data source, in this case the data being pulled for the option buttons is in number format 0 through 10, although that will not always be the case.  My query on the form is based on a client ID number in the data base.  The rule I set up runs when the query field is not blank, and as a second condition if the value of the secondary data field is equal to 0, when these are both true then the rule sets the option button control to equal a value that is the same as the “value when selected” of the first of the 4 option buttons. I would go on and make almost identical rules for each of the other 3 option buttons that selected the proper button for each value of the database field by using OR statements in the conditions for the rules,the 2nd button being selected if a value of 1-2 is returned, and more of the same for the last two buttons with 3-6 and 7-10. 

    The net result of all this is when I preview the document and type an id number into the query field in the document, the other fields, fill out fine for the record indicated, but even with all the rules set to run when my query field is not blank none of the option buttons are selected when the query runs.  If I try clicking on any of the option buttons then the selection appears and changes to the correct option button, and even if I have a default button selected, the selection does not change automatically once the query is run.  That lack of an automatic selection/change without any user action needed is what I am trying to figure out how to overcome.  Hope the details here are clearer than the first post.  I have looked over your response here and am unsure how an action set up on form load could help, but would be grateful on any comment to point out what I am missing/misunderstanding.(By the way thank you, I see what you were saying that I can point the rules straight to the data connection to the database, and not need to data to be pulled to a field in the form, and then compared, I have pulled that extra step out of the form.)Thank you for your time, J
  • 09-08-2011 03:24 PM In reply to

    Re: Filling Option Buttons from a data source?

    Hi -

    Okay, I think what you are saying is that you currently have your form working correctly - you run your query and data is returned, and your rules are populating fields correctly. However, none of your option buttons are being set. Is the data being returned that is being used to set your field bound to your option control valid? That is, if you have a field named "option", and you have a set of 3 option buttons bound to that field, and the "selected" values of those buttons are 1, 2, & 3 respectively, what would you anticipate happening if your rules are setting the "option" field to "a"? None of the buttons would be selected, right? To debug, it may be easier if you drag the field currently bound to the option buttons control onto your form as a text field, so you can be sure that you know the value it is being set to.

    Hope that helps...

    Hilary Stoupa

  • 09-13-2011 10:58 AM In reply to

    • Jtcom
    • Top 500 Contributor
    • Joined on 06-16-2011
    • Posts 34

    Re: Filling Option Buttons from a data source?

    Thank you for the suggestion about checking to make sure my value, matched my pulled data.  I did double check this and indeed they do mach properly.  To clarify the option buttons are not being set, but on the form after a query is made I have to attempt to select one of the option buttons manually before it auto selects the correct value.  From the answers I have gotten here though I get the impression that I am on the correct track in using rules based on the value in, or pulled from a database to set the value of the field that the option buttons are bound to, correct?  If that is the case, at this point, unless there are any other suggestions about what I may be missing I will likely proceed with users manually selecting all option buttons, as having them select an option to auto populate an option does not seem a timesaver. 

    Thank you Hilary and Ernesto for your thoughts on the topic 

     

  • 09-14-2011 09:02 AM In reply to

    Re: Filling Option Buttons from a data source?

    I'm sorry it didn't work out. It should, in theory, but troubleshooting your form, your data connection, etc is not something we can easily do over the forum. We provide paid support, via Livemeeting, in case you are interested now or in the future. Thanks!

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 09-16-2011 10:57 PM In reply to

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    Re: Filling Option Buttons from a data source?

    A possibility: Check for empty spaces either side of the values being returned from your datasource.

    A way to check is just drag the datasource onto a blank view and make a repeating table of the data.

    Then open the form, do a query of the datasource and change to that new view.
    Highlight the values in the repeating table corresponding to the radio buttons and see if there is 'more' being highlighted than just the values.

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.