Set the default values for a form InfoPath 2007

Author: mety Labels::



When designing a Microsoft Office InfoPath 2007 form template, you can assign default values to controls that are bound (bind: To connect a control to a field or group in the data source so that data entered into the control is saved. When a control is unbound, it is not connected to a field or group, and so data entered into the control will not be saved.) to fields (field: An element or attribute in the data source that can contain data. If the field is an element, it can contain attribute fields. Fields store the data that is entered into controls.) in the form template. A default value is the value that appears automatically in a control when the user opens a form to fill it out.

When you design a form template, you can assign default values to controls in order to help users fill out your form faster. For example, if you create an employee expense report form template, you can assign today's date as the default value for a date picker control. As a result, the current date is automatically populated in the date picker control when the user opens the form, and they do not have to manually enter the date.
You can set default values in your form template by:


Set the default value for a control

When you set a default value for a field in your form template, you are specifying the value that should appear automatically in the control when a user fills out a form based on that form template.
  1. If the Data Source task pane is not visible, click Data Source on the View menu.
  2. In the Data Source task pane, right-click the field whose default value you want to set, and then click Properties on the shortcut menu.
  3. Click the Data tab.
  4. Do one of the following:
    • To use a specific value as the default value, type the default value in the Value box.
    • To use an XPath expression to create the default value, click Insert Formula Button image, and then in the Insert Formula dialog box, create the XPath expression. Tip To automatically update the value in the selected field each time the formula is calculated, select the Update this value when the result of the formula is recalculated check box in the Field or Group Properties dialog box.
  5. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.
ShowTechnical details
When you set the default value for a control, you are also setting the default value for the field to which that control is bound. Any control that is bound to that field will be assigned the same default value.
If the default value is a specified value, that value is stored in the template.xml file associated with the form template. To programmatically change the default value, change the value of the appropriate field in the template.xml file. If the default value is the result of an XPath expression, the expression is stored in the manifest.xsf file, in the xsf:calculatedField element for the field.

Set the default value using a rule

You can use a rule to set the default value of a control based on the value of another control. A rule is an action that occurs when a condition in the form is met. For example, you might design a form template with a control for the state and another control for the ZIP Code. When a user enters a ZIP Code in the ZIP Code control, the State control is automatically populated with the correct state.
In order to complete this procedure, you must have two controls in your form template — one that the user will enter data into, and one that will be populated with a default value, based on the data entered into the first control.
  1. Double-click the control that the control with the default value will be based on. For example, in the case of the State and ZIP Code controls, you would double-click the ZIP Code control.
  2. Click the Data tab.
  3. Under Validation and Rules, click Rules.
  4. In the Rules dialog box, click Add.
  5. In the Name box, type a name for the rule.
  6. To specify when the rule should run, click Set Condition.
  7. In the Condition dialog box, enter the condition, and then click OK. For example, if you want a default value to be added to a control when the user enters data into another control, in the first box, click the field that the user will enter data into, click is equal to in the second box, and in the last box, enter the data the user will enter into the control.
  8. In the Rule dialog box, click Add Action.
  9. In the Action list, click Set a field's value.
  10. Click Button image next to the Field box, and then in the Select a Field or Group dialog box, click the control whose default value you want to set.
  11. Do one of the following:
    • To use a specified value as the default value, type the value in the Value box, and then click OK.
    • To use an XPath expression to create the default value, click Insert Formula Button image, enter the formula in the Insert Formula dialog box, and then click OK.
  12. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

Set all of the default values for a form

If you know all of the controls in your form template that will have a default value, and that the default values are not based on rules, you can set all of the default values at once.
  1. On the Tools menu, click Form Options.
  2. Click Advanced in the Category list, and then click Edit Default Values.
  3. In the Edit Default Values dialog box, select the field whose default value you want to set.
  4. Do one of the following:
    • To use a specified value as the default value, type the default value for the field in the Default value box, and then click OK.
    • To use an XPath expression to create the default value, click Insert Formula Button image, and then in the Insert Formula dialog box, create the XPath expression. Tip To automatically update the value in the selected field each time the formula is calculated, select the Update this value when the result of the formula is recalculated check box in the Edit Default Values dialog box.
  5. Repeat step 3 and step 4 for each field whose default value you want to set.
  6. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

0 comments |

Labels

Blog Archive

Powered by Blogger.

I made these pages for me and my friends to help solving the problem we face regarding Computer & internet, if anyone wants me to answer a question or find out about some information please send me email and I will try to reply.*P.S. some of the article I wrote and the other I found on the internet I posted them in sprit of learning and shearing, please forgive me if you found something you don’t want to be in my blog, email me and I will delete them. Thank you for your interest in my pages.امل نجم Amal Nagm

banner 1 banner 2