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.

ADVERTISEMENTS

Problem

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).

Solution

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.

Discussion

The following instructions apply to InfoPath 2010, but this functionality can also be implemented in InfoPath 2007.

You can achieve this functionality as follows:

  1. In InfoPath 2010, create a new Blank Form template.
  2. On the Home tab under the Controls group, click Text Box to add a text box control to the form template.
  3. Click the text box control to select it.
  4. On the Properties tab under the Properties group, click Default Value.
  5. 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.
  6. 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))

  7. On the Field or Group Properties dialog box, click OK.
  8. 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).

 


Related Posts

 

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.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services