Search This Blog

Thursday, September 9, 2010

InfoPath-Automatically change the first letter of a word/sentence to upper case

Problem


When an InfoPath user types in the text "example" or "this is really cool!", you would like this text to
automatically be changed into "Example" or "This is really cool!" when the user leaves the text field.

Solution


Use the concat(), substring(), translate(), and string-length() functions
in a formula to format the text field.


Discussion


You can accomplish this functionality as follows:



  1. Create a New Blank Form in InfoPath.

  2. Add a Text Box control to the form.

  3. Double-click on the text box control to open its Properties dialog box.


  4. Click on the Insert Formula button behind the Default Value field.

  5. Enter the following formula on the Insert Formula dialog box:


    concat(substring(translate(., "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1, 1), substring(., 2, string-length(.) - 1))



  6. Click on the OK button when closing all open dialog boxes.


The first letter of a word or sentence typed into the text box should now automatically be converted into an upper case letter
whenever the text box loses the focus.

4 comments: