InfoPath: Create Common Multiple Choice Selections
In InfoPath, when using certain controls such as the Drop-Down List Box, Combo Box, List Box, or Multiple Selection List box, there are several different ways that you can obtain the list of choices that are available to people filling out the form.
- Enter choices manually – This option allows you to simply click the Add… button below and type in the values for each choice, and use the Move Up and Move Down buttons to rearrange the order.
- Get choices from an external data source – This option allows you to select an existing data connection, such as one that receives a SharePoint list. This way, the selections can be dynamic. This is the best option to use when the values in the list change frequently. It allows you to simply change the source location, such as the items in a SharePoint list, instead of having to re-type the options in and re-publish the form.
This blog post is all about that other option, called Get choices from fields in this form.
This middle option is pretty useful in a couple of situations:
- You have a list of fairly static choices, but you need to use them in several places in your form. A good example is a survey. Commonly, there need to be many drop-down boxes in a survey, but they have all the same choices, such as Yes, No, Maybe.
- A different situation, which I don’t come across often, is when there is a repeating table or section somewhere in the form, and the values that have been filled in there, need to be the values to select from in your drop-down box.
This blog post is about option 1 above. A survey with the same set of answers being needed multiple times in the form.
Here’s how to create some choices “Yes, No, or Maybe”, using that middle option in your drop-down box, and use it in many places in the same form:
- In InfoPath Designer, in the Fields pane on the right, right click the MyFields folder (root folder) and click Add…
- Name it SurveyChoiceGroup, select Group as the type, and click OK.
- Right-click on SurveyChoiceGroup, and click Add… Name it SurveyChoice, and click OK.
- Name it SurveyChoice, check the box next to Repeating, and click OK.
- Your new structure in the Fields pane on the right should look like this:
- On the Data tab, click the Default Values button.
- Click the drop-down on the SurveyChoice field, and select Add another SurveyChoice below.
- Do this one more time, so that there are three different Survey choices under the SurveyChoiceGroup.
- Click to select the first of the three SurveyChoice fields. In the Default value field, type Yes
- Click to select the second SurveyChoice, type a default value of No, and then for the third, type a default value of Maybe. Click OK.
- Put a drop-down box on your form, and open its properties screen.
- Select Get choices from fields in this form, and choose SurveyChoice. Click OK, click OK.
Now, when you publish or preview your form, you can see that when you click the drop-down, it shows the 3 choices of Yes, No, or Maybe. You can create multiple drop-downs or any type of selection boxes, and use that same list of survey choices in all of them. Then, if the list of choices need to be edited, you can just do it in one place. Of course, this can always be done by creating a data connection to a SharePoint list, but for such a simple set of choices, all of that may not be necessary. This is just another option.