Selecting dropdown values from database - InfoPath Dev
in

InfoPath Dev

Selecting dropdown values from database

Last post 01-04-2013 04:37 AM by learninginfopath. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 03-03-2009 10:32 AM

    Selecting dropdown values from database

    Hello,

    I have a form that pulls values from a database for a certain record when a "get data" button is pressed. It is easy to populate regular text boxes, but how would I populate dropdowns? I want to have 3 values for example "yes, no, maybe" in the dropdown and those are the only values that can exist in the table for that column.  How do I get InfoPath to pull up the value that corresponds in the database for that record? The user must also be able to change the value it returns to any of the other 2 values.

    So lets say the user pulls up id = 5 from the database and option = no. I want "no" to be selected automatically in the dropdown, but "yes" and "maybe" also need to be in there and be selectable.

    Any ideas?

    Thanks,
    Igor

  • 03-03-2009 12:56 PM In reply to

    Re: Selecting dropdown values from database

    Well, you simply set the value of the field to which the drop down is bound to the correct value. So, if your drop down list has the values of 'no', 'yes', and 'maybe' manually entered as the choices, and it is bound to the 'option' field, by setting the value of the option field to 'no', 'no' would be the selected item from the drop down. Remember, you are dealing with case sensitive comparisons, so 'No' will not equal 'no'.

    Hilary Stoupa

  • 03-04-2009 09:07 AM In reply to

    Re: Selecting dropdown values from database

    This is what I am doing but the dropdown field is blank when the data is retrieved. As soon as I change it back to a textbox, it populates fine.  It's already returning the correct string from the database, but for some reason its not mapping it correctly to the pre-defined dropdown values.

    Igor

  • 03-04-2009 09:17 AM In reply to

    Re: Selecting dropdown values from database

    Also, if I select "Look up values in the form's data source" it does return the value from the DB correctly, but I can't manually add the other 2 values that I need to be in the dropdown.

  • 03-04-2009 09:29 AM In reply to

    Re: Selecting dropdown values from database

    Hilary Stoupa:

    ...by setting the value of the option field to 'no', 'no' would be the selected item from the drop down. ...

    Hillary, I don't want to set the value to 'no' because it has set itself to whatever the value of the field returned from the DB. So if it's 'yes' or 'maybe', either of those options should be the default. 

    Thanks,

    Igor

  • 03-04-2009 01:15 PM In reply to

    Re: Selecting dropdown values from database

    I finally figured it out. It was simply that the field had an extra whitespace appended to the end of it! Setting default value to normalize-space(.) fixed everything.

  • 03-04-2009 01:34 PM In reply to

    Re: Selecting dropdown values from database

    It seems like this is a bug in InfoPath. Whenever you set the default value for a dropdown like I did above, and you go back to the dropdown properties, the "default" value is removed and InfoPath doesn't see that I have already specified it in the field properties. If you need to make changes in the properties, you will need to temporarily assign a default value so that InfoPath with allow you to save, then you need to go back to field properties and set it back to what you had before.

  • 03-05-2009 06:32 PM In reply to

    Re: Selecting dropdown values from database

    What this tells us then:

    igor92128:
    As soon as I change it back to a textbox, it populates fine.  It's already returning the correct string from the database, but for some reason its not mapping it correctly to the pre-defined dropdown values.

    Is that the values in the drop down do not precisely match the values coming from your database. Are you database columns a fixed width, perhaps?

    Hilary Stoupa

  • 01-04-2013 04:37 AM In reply to

    Re: Selecting dropdown values from database

    Hi Igor,

    Can you please explain how you solved the problem. We are having the same problem(struck up) and not able to figure out the problem.

     

    Thanks in Advance.

     

     

     

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