3 Ways to create a hidden field in InfoPath 2010
Learn which 3 methods you can use to hide fields in InfoPath 2010 and when to use each to create an InfoPath 2010 hidden field.
I’ve previously written about how to create a hidden field in InfoPath 2007. You can use this same technique to create an InfoPath 2010 hidden field.
Hidden fields are typically used in InfoPath to enable actions without displaying data to the user.
An InfoPath 2010 hidden field may or may not be bound to a control on a form. If you do bind an InfoPath hidden field to a control, you must use conditional formatting to hide the field in InfoPath 2010 to be able to keep the value of the field bound to the control hidden.
This brings us to the 3 ways you can hide a field in InfoPath 2010:
- Create a field in the Main data source of an InfoPath form and do not bind it to a control on the form.
- Use a field in a secondary data source and do not bind it to a control on the form.
- Bind a field to a control on a form and use conditional formatting to hide the field in InfoPath 2010.
So when should you use which method?
Use method 1 if you want to store the value of the hidden field permanently in the form. A good example of this is if you want to submit an InfoPath form and then on subsequent times when the form is opened, you want to make fields on the InfoPath form read-only. In such a case, you would use an InfoPath hidden field to keep track of when the form is submitted. And because the submitted status of the form should be persisted throughout the lifetime of the form, it means you should store the value of the hidden field in the Main data source of the form.
Use method 2 if you temporarily want to store a value in a field you do not want to display to the user. Helper fields are good candidates for InfoPath 2010 hidden fields that live in secondary data sources. Because you typically do not want to store data entered in helper fields in an InfoPath form and because any data in a secondary data source is never stored in the InfoPath form itself, secondary data sources are ideal for providing helper fields. For an example of the use of a helper field, see Using the AVG function in InfoPath.
Use method 3 if you require a field to be sometimes hidden and sometimes not, for example, if you want to use a section control to display a message when a check box is selected or deselected.
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.