Quick Tip: Format text with proper case in InfoPath
Learn how you can use InfoPath functions in a formula to automatically capitalize the first letter of text that is typed into a text box on an InfoPath form when the text box loses the focus.
You have a text box on a form in InfoPath and would like to have the first letter of any word typed into that text box to automatically be capitalized (changed to uppercase).
Use a formula consisting of the concat(), translate(), substring(), and string-length() InfoPath functions to capitalize the first letter in any text that is typed into the text box.
The following instructions apply to InfoPath 2010, but this functionality can also be implemented in InfoPath 2007.
You can achieve this functionality as follows:
- In InfoPath 2010, create a new Blank Form template.
- On the Home tab under the Controls group, click Text Box to add a text box control to the form template.
- Click the text box control to select it.
- On the Properties tab under the Properties group, click Default Value.
- On the Field or Group Properties dialog box on the Data tab in the Default Value section, click the Insert Formula button behind the Value text box.
- On the Insert Formula dialog box, type in the following formula into the Formula text box, and click OK.
concat(translate(substring(., 1, 1), "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), substring(., 2, string-length(.) - 1))
- On the Field or Group Properties dialog box, click OK.
- Press F5 to preview the InfoPath form.
Now whenever you type in a piece of text into the text box and tab away from the text box, the first letter of the first word in the text box is changed to uppercase (capitalized).
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 of S.Y.M. Wong-A-Ton. 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, S.Y.M. Wong-A-Ton.