Filling Out Forms


In this chapter, you will learn how to

  • Open and fill in a moderately complex InfoPath form
  • Test InfoPath s conditional formatting and data validation features
  • Save, preview, and print the data document you filled in
  • Relate the data you enter in a form to the content of its XML data document
  • Merge two or more data documents to produce a summary form

For more information

  • Refer to the section Opening a Sample InfoPath Form, in Chapter 1.
  • Refer to the section Getting Help with InfoPath, in Chapter 1.


To work through this chapter

  • You should be familiar with Microsoft InfoPaths user interface (UI), which is described in Chapter 1, Presenting InfoPath 2003 SP-1.
  • You should be familiar with basic HTML 4.01 FORM elements, such as INPUT and its control types.
  • You should have installed in your C:Microsoft PressIntroducing InfoPath 2003Chapter## folders the sample files from the CD that accompanies this book. The Using the Accompanying CD section in the Introduction describes the sample file installation.

InfoPaths primary objective is capturing data and saving it as an XML data document, so most InfoPath users willor at least shouldrun InfoPath in data entry mode only. This chapters primary objective is to show you how InfoPaths intuitive, Microsoft Officebased UI makes it easy for users to fill in moderately complex forms that emulate paper business documents.

As you progress through this chapter, youll gain expertise in using InfoPaths repertoire of basic controls and lists, and learn the special techniques that InfoPath uses to capture semi-structured data. A working knowledge of the data entry process is essential before you begin designing your own forms in Part II.

Filling Out the Status Report Form

The Status Report form you opened in Chapter 1 is only one of the 25 sample forms included with InfoPath 2003. Status Report includes examples of most basic data entry controls ”contained in tables, optional sections, and repeating tables ”making it a good candidate for a detailed demonstration of InfoPath s data entry process.

 SP-1   To open the Status Report form for this data entry exercise, follow these steps.

Open the Status Report form

  1. Launch InfoPath, if it isn t running, which opens the Fill Out A Form dialog box. If InfoPath is running and the Fill Out A Form task pane isn t visible, open the task pane s drop-down menu, select Fill Out A Form, and click the More Forms link to open the Fill Out A Form dialog box with the Recently Used Forms list active.
  2. If you opened the Status Report form in the section Opening a Sample InfoPath Form, in Chapter 1, the More Forms list includes the Status Report form. In this case, you can double- click the Status Report icon, and skip the following step.
  3. Click the Sample Forms link under the Form Categories heading to display the Sample Forms list, scroll to the bottom of the list, and double-click the Status Report icon.

InfoPath loads the StatusReport.xsn template, and creates an empty Form1 XML data document in memory. Now you re ready to begin entering data.

Working with the Date Picker Control

The date picker control is a text box that displays dates in the Short Date format that s set in Control Panel s Regional And Language Options tool. The date picker control is in the left cell of the uppermost table of the form. As mentioned in Chapter 1, Microsoft JScript code behind the Status Report template sets the default value of the date picker control to your computer s system date.

To change the date, click the button that shows the calendar icon to the right of the Date text box to open the pop-up calendar. Click a different day of the month, as shown in Figure 2-1, to close the calendar. Alternatively, change the month by clicking one of the two arrow buttons in the calendar and then clicking the date.

click to expand
Figure 2-1: You can use the date picker control to postdate a report.

Entering Data in Text Boxes

Text boxes are InfoPath s most widely used control. Following are the most important data entry characteristics of text boxes:

  • A text box bound to a string field can contain letters , numbers , symbols, and punctuation.
  • A text box bound to an integer numeric field can contain only numbers and plus signs or minus signs. You can add decimal points, digit grouping symbols, and currency symbols to a double numeric field.
  • Digit grouping and currency symbols are permitted only when the template applies special number formatting the text box.
  • You can t apply character formatting ”such as boldface or italic attributes ”to a text box s contents.

Typing data in a standard (string) text box is a no-brainer, so fill the six text boxes (Name, Manager Name , E-mail Address, and so on) in the second table with sample text. Moving the mouse pointer into a text box or rich text box changes the pointer from a selection arrow to an I-beam. The text box s default light gray outline changes to dark gray, which indicates that the control is enabled for text entry. When you click or tab into the box to enter text, the border changes to blue, indicating that the control has the focus.


Entering sample text in all fields is important
Add text and other entries to every control on the form, including repeating tables contained in optional sections, which you will encounter later in this chapter. Doing this creates an XML data document with fields (elements) that have content you can relate to your original entries. Making entries in all fields, with the exception of an optional Task List, also is necessary to demonstrate the fields of data documents that will be merged when you reach the section Merging Forms, later in this chapter.

The default tab order for controls in tables is top- to-bottom, left-to-right . Pressing the Tab key repeatedly sets the focus to each active control on the form. When you reach the end of the form, the focus cycles to the topmost control ”in this case, the date picker.

Inserting Symbols and Special Characters

 SP-1   InfoPath s Insert menu has a simplified version of Microsoft Word s Symbols dialog box. To add a special symbol, such as , follow these steps.

Insert a special symbol

  1. Choose Insert, Symbol to open the Symbol dialog box.
  2. Select Verdana, InfoPath s default font for most languages, from the Font list.
  3. Many commonly used symbols appear by default in the Recently Used Symbols group, as shown here. If you don t see the symbol you want in this group , scroll up or down in the main symbol list until you do.
  4. Select the symbol as shown here:

    click to expand

  5. Click Insert or double-click the symbol to add it to the text box, and click Close to close the dialog box.

Testing the Office Spelling Checker

Deliberately misspell a word in the Project or Department text box to verify that the Office spelling checker is operational, which is indicated by a wavy red line under the misspelled word. (The spelling checker is disabled for the other four text boxes.) Press F7 or choose Tools, Spelling to display the Spelling task pane, which offers suggestions for correcting the error, as shown in Figure 2-2. Select the appropriate suggestion and click Change to correct the typo.

click to expand
Figure 2-2: The Spelling task pane suggests a correction for a typo in a text box.

Setting Spelling, Language, and AutoComplete Options

The Spelling task pane has links to the Options and Set Language dialog boxes. Click the Spelling Options link to open the Options dialog box, or choose Tools, Options and click the Spelling tab. Figure 2-3 shows InfoPath s default spelling options. You might want to select the Ignore Words In UPPERCASE check box to skip checking acronyms and abbreviations, such as XSD (for XML Schema Definition).

click to expand
Figure 2-3: The Spelling tab of the Options dialog displays InfoPath s default spelling checker options.

Click the Set Language link or choose Tools, Set Language to open the Language dialog box, as shown in Figure 2-4.

Figure 2-4: Change the spelling checker s default language in this dialog box.

InfoPath s AutoComplete feature is linked to an Internet Explorer setting, which might be disabled on your computer. If you clear one of the text boxes, tab out and back in to it, and then type the initial letter of a previous entry, AutoComplete for forms opens a drop- down list of prior entries beginning with the same letter, as shown in Figure 2-5. If this doesn t work for you, AutoComplete probably is disabled.

click to expand
Figure 2-5: The AutoComplete feature displays a list of previous values that start with the first letter you type in the text box.

The AutoComplete options are buried in Internet Explorer s Internet Options dialog box. AutoComplete remembers URLs for Web pages you visited recently, data you ve entered in HTML forms, and user names and passwords for forms. InfoPath uses the data in forms feature only. Any AutoComplete changes you make are applied to InfoPath and to all your future Internet Explorer sessions. To enable AutoComplete for forms, follow these steps.

Enable AutoComplete for forms

  1. Choose Tools, Options, and select the General tab in the Options dialog box.
  2. Click the Internet Options button to open Internet Explorer s Internet Properties dialog box, select the Content tab, and then click the AutoComplete button to open the AutoComplete Settings dialog box, shown here:

  3. Enable AutoComplete for InfoPath by selecting the Form check box. To disable AutoComplete, clear all the check boxes. Click OK three times to return to filling out your form.

Formatting Rich Text Data

The Summary control is a rich text box that lets you add unstructured information to a form. Unstructured data isn t governed by the form s underlying XML schema rules, as indicated by its official any data type. (InfoPath calls this data type XHTML.) Almost anything goes in a rich text box ”formatted text, paragraphs, tables, bulleted and numbered lists, hyperlinks , and graphics images.

As mentioned in the section Opening a Sample Form, in Chapter 1, giving the focus to a rich text box control enables the Office-standard Formatting toolbar s buttons. The process of formatting a rich text box s content is almost identical to formatting the text of Microsoft Word version 2000 and later documents. Compatibility with Word documents extends to Clipboard operations also. You can copy and paste formatted rich text box content into a Word document and vice versa. Depending on the version of Microsoft Word you re using, a few formatting features ”such as paragraph indentation ” might disappear.


Displaying formatting shortcut keys
Most Office users are familiar with shortcut keys for boldface, italic, and underline text formatting. InfoPath has additional shortcut keys for text alignment, indenting, and outdenting. To display the shortcut key in the ScreenTip for toolbar buttons that have shortcut keys, choose Tools, Customize, select the Options tab, and select the Show Shortcut Keys In ScreenTips check box.

The following two procedures demonstrate the character and paragraph formatting capabilities of the rich text box s XHTML editor.

Format text characters

  1. Type about six lines of text into the Summary rich text box. (Look ahead to Figure 2-4 for suggested text that you format later.) Press Enter after each line to generate paragraph breaks. The text box expands vertically to accommodate the added content.
  2. Select a word or phrase in the first line, and apply underline formatting by clicking the toolbar s Underline button or pressing Ctrl+U.
  3. Repeat step 2, but apply boldface formatting by clicking the Bold button or pressing Ctrl+B, and add italic formatting by clicking the Italic button or pressing Ctrl+I.
  4. Select another word or phrase, and click the Highlight button to add a yellow (or other color you choose) background to some text.
  5. Repeat step 4, but click the arrow to the right of the Font Color button and choose a color to apply to the selected text.
  6. In the second line, select a word or two, and change the font size from the default 10 points to 12 points. Select another couple of words, and change the font family from the default Verdana to Times New Roman.

Format paragraphs

  1. Position the insertion point in the second line, and click the Increase Indent button or press Ctrl+M to indent the paragraph.
  2. Position the insertion point in the third line, and click the Numbering button, which has no shortcut key, to start a numbered (ordered) list.
  3. Move to the next line, and click the Bullets button or press Ctrl+Shift+L to start a bulleted (unordered) list.
  4. Select the next line, and click the Center button or press Ctrl+E to center the text.
  5. Select the last line, and click the Left button or press Ctrl+R to right-align the line.

At this point, your Summary rich text box should appear similar to that shown in Figure 2-6.

click to expand
Figure 2-6: Your Summary rich text box should now contain formatted text and paragraphs similar to those shown here.

Working with Bulleted and Numbered List Controls

InfoPath s bulleted lists correspond to HTML unordered lists, but save their content in a repeating section of the data document. InfoPath handles the formatting of bulleted lists. The Status Report form doesn t demonstrate a numbered list, but numbered lists behave identically to bulleted lists. Plain lists omit the bullet or number. You can do the following with bulleted, numbered, and plain lists:

  • Add to the list by selecting (giving the focus to) an item and pressing Enter to add the empty item below the selected item.
  • Delete an item by selecting it and pressing Delete. Lists must contain at least one item, but the item can be empty. If you want a single list item, delete all other blank list items before entering text in the remaining item.
  • Format selected characters with boldface, italic, and underline attributes.
  • Change the font family and font size of all or part of the text.
  • Apply highlighting to, and change the font color of, selected characters.

Figure 2-5 shows the Last Period, This Period, and Issues lists in the Status Report form with deleted and added items and character formatting applied. Use the techniques you learned in the earlier section Format text characters to duplicate the list item formatting shown in Figure 2-7.

click to expand
Figure 2-7: This Status Report document has three bulleted lists with deleted, added, and formatted items.

Adding Tables to Rich Text Boxes

The Notes control is the Status Report s second rich text box control. You use this control to experiment with adding and formatting HTML tables, copying and pasting tables to and from other Office applications, and adding hyperlinks and pictures. Manipulating tables inside rich text boxes is similar to working with Word tables, as you ll discover in the three following procedures.

Insert and modify an empty table

  1. Give the Notes rich text box the focus by clicking it, and choose Insert, Table to open the Insert Table dialog box, which defaults to 5 columns and 2 rows, as shown here:

  2. Change the number of columns to 2, and click OK to add the table, which opens with the insertion point in the first cell of the top row and all Formatting toolbar buttons enabled. Active tables have a rectangular selection button in the upper left corner.
  3. Choose View, Toolbars, Tables to display the Tables toolbar.
  4. Click and drag the right edge of the table to reduce its width as much as possible, and then click and drag the vertical divider to create columns of approximately equal width.
  5. Drag the mouse pointer across the top row to select the two columns, and click the Merge Cells button on the Tables toolbar or choose Table, Merge cells to create a single cell in the top row.
  6. Type some text, such as Inserted Table, in the top cell, press Ctrl+E to center the text, select the text, and press Ctrl+B to apply the boldface attribute.
  7. Enter 1000 and 2000 in the bottom row s cells. Position the insertion point in each cell, and press Ctrl+R to right-align the numbers.

 SP-1   Drawing tables
Drawing tables using a pencil cursor is an alternative to inserting tables with a specified number of rows and columns. To draw a table, choose View, Toolbars, and select the Tables toolbar. Click the Draw Table button on the Tables toolbar and add cells to the table with the pencil cursor. You ll probably find, though, that inserting tables is easier than drawing them.

At this point, your added table appears as shown in Figure 2-8.

click to expand
Figure 2-8: When you insert a table into a rich text box, its selection button appears at the table s top left corner.

Modify table properties

  1. Click the table s selection handle to select all cells, and then click the Table Properties button on the Tables toolbar or choose Table, Table Properties to open the Table Properties dialog box, which opens with the Table tab selected. InfoPath s Table Properties dialog box is a downsized version of Word 2003 s implementation.
  2. Accept the default Left Horizontal Alignment option, or click the Center or Right Horizontal Alignment button. Center is shown selected here. If you change the alignment, click Apply.

  3. Select the Row tab, and accept the default minimum row height, or select the Automatically Set Row Height option, as shown here, to adjust the row height of the selected row or rows to accommodate their contents. You can select px (pixels), in (inches), cm (centimeters), or pt (points) as the unit of measurement when you specify a minimum row height. Click the Next Row button to change the row heights of successive rows. If you make a change, click Apply.

  4. Select the Column tab, and optionally , change the width of the columns (A and B for this example), as shown here. Click Apply.

  5. Select the Cell tab to change the vertical alignment and padding of the selected cells only, as shown on the next page. ( Padding is the distance between the edge of the cell and the text or other element contained in the cell.) Click Apply, and then click OK to close the dialog box.

Figure 2-9 shows the effect of horizontally centering the table, changing the column widths to 75 pixels, vertically centering the cells, and changing all cell padding values to 5 pixels.

click to expand
Figure 2-9: This table is the modified version of the table from Figure 2-6.

Modify table borders and shading

  1. Click the table s selection button to select all cells, and then click the Borders And Shading button on the Tables toolbar or choose Table, Borders And Shading to open the Borders And Shading dialog box with the Borders tab selected. Like the Table Properties dialog box, InfoPath s Borders And Shading dialog box exhibits a Word 2003 heritage.
  2. You can t change the table s border style, width, or color, but you can remove the default borders by clicking the buttons in the Border section, as shown here. The buttons toggle the associated border on and off.

    click to expand

  3. Select the Shading tab, and then click the Color option button to add a background color to the selected table cells. At the top of the color picker, you can select one of the six standard colors of the form s color scheme ”Blue for all sample forms ”as shown here, or you can click More Colors to define a custom background color.

    click to expand

See Also  

You ll learn more about the use of tables in InfoPath s design mode in Chapter 5, Laying Out Forms, and about color schemes in Chapter 7, Formatting Forms.

Copying Tables from and to Other Office Applications

Microsoft Word, Excel, Access, and other Office applications share a common Clipboard format for transferring tabular data between applications. If you have Access version 2000 or later installed, you can select and copy rows of a table or query in Datasheet view to the Clipboard and paste the data into a rich text box. The same process also works for Word tables and Excel cells. Figure 2-10 illustrates copying and pasting data from Access into InfoPath and Excel and then copying and pasting the Excel data into the rich text box.

click to expand
Figure 2-10: You can paste tables you copy from Word, Access, and Excel into a rich text box.


Separating rich text data with horizontal lines
Figure 2-10 shows two horizontal separator lines between the three tables. To add a separator between two elements, position the insertion point at the end of the first element, and choose Insert, Horizontal Line.

You can select InfoPath table cells and then copy and paste the cells into Word and Excel, but you can t use Edit, Paste Append to add records to an Access table. To add records to an Access table, copy the cells to an Excel worksheet, and then choose Paste Append to add the worksheet s rows to an Access table with the appropriate data structure. In most cases, you can safely ignore the Import Errors message.

Adding Hyperlinks

Rich text boxes can contain hyperlink controls. To add a hyperlink to a rich text box, position the insertion point where you want the text, and choose Insert, Hyperlink to open the Insert Hyperlink dialog box. Type the URL for the site in the Link To text box and the site s description in the Display This Text text box, as shown in Figure 2-11, and then click OK to add the link.

Figure 2-11: Type the hyperlink's URL in the Link To text box and the link text in the Display This Text box.

InfoPath embedded hyperlinks don t behave the same as hyperlinks in Web pages or the hyperlink controls you learn about in Chapter 6, Adding Basic Controls and Lists. You must right-click the embedded link and choose Open Hyperlink from the shortcut menu, as shown in Figure 2-12, to open the destination page.

click to expand
Figure 2-12: You use the shortcut menu to navigate to the Web site specified by the hyperlink control.

Inserting Pictures into Rich Text Boxes

Another use for rich text boxes is displaying graphics images from local files or clip art from the Microsoft Office Clip Art and Media gallery. Inserting images increases the size of your XML data document greatly. For example, the simple Windows Metafile (.wmf) image you add in the following procedure increases the size of the XML file from 7.2 KB to 14 KB at this point in the completion process. You ll see the reason for the file size increase when you examine the saved file later in this chapter.


Placing images in tables
If you want to add text adjacent to an image, insert a one-row, two-column table, and place the picture in one of the cells. Use the Borders And Shading dialog box to remove the cell borders and the Table Properties dialog box to adjust cell padding.

Add a picture from a local file

  1. Position the insertion point where you want the picture to appear, and choose Insert, Picture, From File to open the Insert Picture dialog box with My Pictures as the default folder. If you have a logo or other image file that s less than 15 KB or so in this folder, select it, and skip the next step.
  2. Navigate to a folder containing image files, such as Program FilesMicrosoft OfficeMediaCagcat10. Vector-based files (.wmf, .emf, .eps) are the best bet because they scale better than bit-mapped graphics (.gif or .jpg) files. Select the thumbnail for the image you would like to insert, as shown here:

    click to expand

  3. Click Insert to add the image to the rich text box. If you selected the clip art image shown in the preceding figure, its original size is out of proportion to the form.
  4. Right-click the image, choose Format Picture to open the Format Picture dialog box, and select the Size tab.
  5. With the Maintain Proportions check box selected, type a reasonable size ”such as 80 px ” in the Height text box, as shown here:

    click to expand

  6. Click OK to close the dialog box and shrink the image, as shown here:

    click to expand

If you don t have a suitable image file available, you can select from thousands of royalty-free clip art images that Microsoft provides for Office System users. To add an image from the Office Clip Art gallery, follow these steps:

Insert an image from the Clip Art task pane

  1. Position the insertion point where you want to add the image, and choose Insert, Picture, Clip Art to display the Clip Art task pane.
  2. Type a subject keyword in the Search For text box, and click Go. By default, images in your Program FilesMicrosoft OfficeMediaCagcat10 folder appear first.
  3. Open the Search In list to restrict the search to clip art collections you create with the Microsoft Clip Art Organizer, the Office Collections installed on your computer by Office or InfoPath, or the Microsoft Office Clip Art and Media gallery. You can restrict the file type to clip art by opening the Results Should Be list and clearing all check boxes except Clip Art.
  4. Scroll the thumbnail list to download additional clip art from the Microsoft Office Clip Art and Media gallery, as shown on the next page.
  5. Click the thumbnail image to insert the image at the insertion point location.
  6. Resize and format the image as described in the preceding procedure.

Adding and Filling Out Optional Sections

Optional sections are another feature that distinguishes InfoPath forms from those of structured forms-based applications, such as Microsoft Access and Microsoft Visual Basic. If you don t add an optional section, its elements don t appear in the form s XML data document; InfoPath disregards the section. The ability to add or omit optional sections is the basis for defining InfoPath as a semi-structured XML document generator and editor. Optional sections can contain tables, individual controls, sections, nested optional sections, and nested repeating tables.

The Status Report form has three optional sections ”Time Report, Budget Report, and Task List ”that contain repeating tables. An icon ”a small orange circle with a right- pointing arrow ”and a text instruction line act as a placeholder for an empty optional section. Clicking the Time Report placeholder opens a repeating table embedded in an optional section, as shown in Figure 2-13.

click to expand
Figure 2-13: The Status Report form has optional sections that contain empty repeating tables.

The Time Report repeating table has a static header, a single row for data, and a footer. The data row contains text boxes for the Description, Time Allotted, and Time Spent columns. The % Spent column is a read-only text box that displays the ratio of Time Spent to Time Allotted (multiplied by 100) and formats the value as a percentage. The footer contains read-only text box controls that calculate total Time Allotted and Time Spent values, and the average % Spent value.

To add the optional Time Report section and enter data in the repeating table, follow these steps:

Add and fill out an optional section

  1. Click the Click Here To Insert The Time Report Section placeholder in the Status Report Form to display the optional section and its repeating table.
  2. Press Tab to move to the Description text box, and type a brief description of an activity, such as Read Introducing InfoPath 2003 Chapter 1.
  3. Press Tab to move to the Time Allotted text box, type 2, press Tab to move to the Time Spent column, and type 1.5.
  4. Press Tab to calculate the % Spent and Totals values, as shown here:

    click to expand

  5. Move the mouse pointer to the Description text box to expose the shortcut menu button with the down arrow, and click the button or right-click inside the section to open the shortcut menu for repeating tables, as shown here:

    click to expand

  6. Choose Insert Below to add a new data row below your first entry.
  7. Repeat steps 2 through 4 with different Description and numeric values, as shown here:

    click to expand

The optional section s shortcut menu and shortcut keys do the following:

  • Remove Time Report Deletes the entire Time Report section. If you remove the section accidentally , press Ctrl+Z to undo the operation.
  • Copy (Ctrl+C) Copies the section s contents to the Clipboard.
  • Cut (Ctrl+X) Copies the section to the Clipboard and then deletes the original.
  • Paste (Ctrl+V) Overwrites the contents of the section or inserts the section elements into an added empty section from a Clipboard copy. If you cut the section accidentally, open a new section and paste the Clipboard copy.

Following are the actions you can take with the repeating table s shortcut menu and shortcut keys:

  • Insert Above Adds a new empty data row above the selected row.
  • Insert Below (Ctrl+Enter) Adds a new, empty data row below the selected row.
  • Remove Deletes the selected row. You can recover from an accidental selection by pressing Ctrl+Z.
  • Copy (Ctrl+C) Copies the selected row to the Clipboard.
  • Cut (Ctrl+X) Copies the selected row to the Clipboard and then deletes the original.
  • Paste (Ctrl+V) Overwrites the contents of the selected row with a Clipboard copy of a row.

Sorting a repeating table s rows
To reorganize the sequence of a repeating table s rows, cut the row to be moved, insert a new row at the desired location, and paste the Clipboard copy into the new empty row. InfoPath doesn t offer a command to sort rows of repeating tables.

Understanding InfoPath s Drop Down Lists

The optional Budget Report section s repeating table includes a drop-down list control that lets you choose one of 91 currencies for budgeted and spent amounts, as partially shown in Figure 2-14. All sample InfoPath forms that have currency-formatted text boxes incorporate this drop-down list. U.S. dollars ”USD ($) ”is the default currency for the 1033 (U.S. English) locale.

click to expand
Figure 2-14: The Currency drop-down list lets you select the currency used by the Budget Report s Amount Budgeted and Amount Spent columns.

A drop-down or conventional list control requires a data source to provide its items collection. The data source can be an XML file that you specify as a secondary data source, a manually typed list of entries, or a repeating section in the form s data document. The data source for the Currency list is a secondary data source that s created from an XML data document (currencies.xml) that has three child (sub) elements ” name , symbol , and display . The name and symbol fields bind to the XML data document s name and symbol child elements of the currency element. The display child element provides the parenthetical currency symbol ($) for the Amount Spent column.

Handling Data Entry Errors

The data you collect and save in XML format is only as valuable as its consistency and accuracy. InfoPath includes several features for detecting data inconsistency errors, such as omitting required values or typing letters instead of numbers in controls that specify a numeric data type. InfoPath s name for the process of detecting and prompting users to correct data entry errors is data validation . If you ve applied Access s field and table validation rules, you ll find InfoPath s data validation process to behave similarly.

InfoPath validates the data you enter in a form with the following conformance tests:

  • Data structure conforms to the form s XML schema. The form s schema may have constraints, such as the minimum and maximum number of elements in a repeating section. For example, attempting to add more than the maximum number of rows specified for a section that s bound to a repeating table opens an error message.
  •  SP-1   Presence of data conforms to the form s XML schema. If the schema specifies that a field must have a value (a required field) and the bound control is empty, InfoPath flags the control as having an error by adding a red asterisk to the control. By default, all numeric and date fields require a value.
  • Data type conforms to the schema. If you type letters instead of numbers in a numeric field or an invalid date ”such as 13/13/2003 ”in a date field, the field is marked with an error flag and a dashed red border.
  • Data values comply with declarative validation rules. InfoPath s design mode includes dialog boxes for establishing data validation rules for controls. Declarative refers to operations that you can specify in InfoPath s design UI. Data that fails validation tests are marked with a dashed red border.
  • Data values comply with data validation programming code. If declarative validation rules alone can t handle the data value test, programming code is usually required to handle validation.

Comparing schema conformance and validation rule compliance
XML documents are valid only if they conform to their associated XML schema. For this reason, InfoPath tests schema conformance ”a process called document validation ” before performing declarative data validation tests, which aren t specified by schemas that InfoPath creates for you or from which you create the form design.

The Status Report form doesn t make extensive use of data validation, but data validation is important when you customize a form for your organization s use. For example, Date, Name, E-Mail Address, Project, and Billing Code aren t required fields, but most organizations would require this information to be provided. As another example, you can enter negative numbers in Time Allotted and Time Spent text boxes, as well as the Amount Budgeted text box in the Budget Report s repeating table. Negative numbers make little or no sense for these field values.

See Also  

Chapter 6 shows you how to specify required field values in design mode, and Chapter 8, Validating Form Data, explains in detail the declarative validation process. Part IV, Programming InfoPath Forms, introduces you to adding code behind forms with Visual Basic .NET.

InfoPath has two validation menu choices: Tools, Go To Next Error (Ctrl+Shift+E) and Show Error Message (Ctrl+Shift+S). You ll learn how to use these commands in the procedure that follows .

To test InfoPath s data validation features with the Status Report form, follow these steps.

Test data validation features

  1. Select the value in the Time Allotted text box of the Time Report table s first row, and press Delete. A red asterisk appears in the cell because a null value violates the schema s requirement for a numeric field value, and the % Spent value changes to 100.0.
  2. Add a minus sign to the Time Spent value, which is an obvious mistake that doesn t cause a validation error.
  3. Type abcd or other letters in the second row s Time Allotted text box. The cell s border changes from blue to a dashed red line as a result of a data type conflict with the schema s number specification for this field (double).
  4. If you haven t done so already, add an optional Budget Report section.
  5. Specify -1000.00 as the Amount Budgeted value and 100 as the Amount Spent value. You don t generate a data validation error, but the % Spent value s format changes from normal, black to boldface, red. A declarative conditional formatting (pctSpent > 1) expression causes the format change shown here:

    click to expand

  6. Click inside the Summary rich text box to give it the focus.
  7. Choose Tools, Go To Next Error or press Ctrl+Shift+E to give the empty Time Allotted text box the focus and enable the Show Error Message item on the Tools menu.
  8. Click Tools, Show Error Message to display the strangely dimensioned message box shown here:

    click to expand

  9. Click OK to close the message box and fix the error.
  10. Repeat steps 7 through 9.
  11. Press Ctrl+Z repeatedly until the changes you made in the preceding steps return to original values.

Conditional formatting is related to data validation, but values detected as out of range by conditional formatting don t set error flags. Chapter 7 describes how to apply in design mode conditional formatting to the basic controls that support this feature.

Saving, Previewing, and Printing Forms

 SP-1   After you complete the data entry process, it s time to save your form. Like most other Microsoft Office applications, InfoPath has an AutoRecover feature that automatically saves a current copy of the form. The default AutoRecover interval is 10 minutes. To change the interval, choose Tools, Options to open the Options dialog box, click the Advanced tab, and change the number of minutes in the spin box.

InfoPath is intended to replace printed forms but, like other Microsoft Office applications, InfoPath offers Print Preview and Print dialog boxes. The following sections describe how to save, preview, and print a completed form.

Saving Data Documents

Saving a form s data document is similar to saving any other Office document: press Ctrl+S or choose File, Save or Save As, give the form a name ”InfoPath automatically adds the .xml extension ”and click Save. The basic rule is save early and often, despite the AutoRecover safety net.


Looking for the File, Properties dialog box?
Most other Office applications, such as Word, Excel, and Access, save documents in compound document files (DocFiles), which include a properties element for adding information about the file. InfoPath generates plain-text XML files that don t include file properties data. Thus, you won t find a Properties item the File menu. XML, after all, is intended to be self-describing .

The primary issue when saving forms is how to name and where to locate them; InfoPath s defaults are Form1.xml in your My Documents folder. Unlike other Office applications, InfoPath s Options dialog box doesn t offer a default file folder setting. Collecting all your files in subfolders of My Documents is a recommended practice. Most network administrators back up each client PC s My Documents folder and its subfolders nightly to a file server, and a single My Documents folder simplifies migrating to a new or repaired computer. If you follow this recommendation, create an InfoPath subfolder with sub-subfolder names by template, such as My DocumentsInfoPathStatusReport.

InfoPath s developers could have set the default form name to TemplateName 1.xml or TemplateNameYYYYMMDD .xml, where YYYYMMDD is the date, but they didn t. The Status Report form doesn t have a project number field, so for example you might choose a part of a Billing Code that represents the project number ”6789 for this form. A file name such as SR6789-1.xml makes sense for a project s first status report, as shown in Figure 2-15. The choice is up to you, but be consistent when naming data document files.

click to expand
Figure 2-15: Save completed sample InfoPath data documents in your My DocumentsInfoPath StatusReport folder.

Previewing and Printing Forms

The 25 InfoPath sample forms are designed to resemble their paper business form counterparts, and many sample forms have signature blocks at the bottom. The sample form designers apparently don t believe that InfoPath will bring about the elusive paperless office ”at least not in the near future.

 SP-1   InfoPath shares Office-standard print preview and printing features. The default printing margins, which you set in the Page Setup tab of the View Properties dialog box, are 0.75 inch on all sides for English measurement units. To open the View Properties dialog box, choose File, Page Setup. Chapter 10, Adding Views to a Template, shows you how to apply printer settings to individual views of a form. The Status Report form has only a single (default) view.

Choosing File, Print Preview or pressing Ctrl+F2 opens the Print Preview window, shown in Figure 2-16. InfoPath doesn t print form background colors, such as those applied to Status Report s top (heading) table.

click to expand
Figure 2-16: InfoPath s Print Preview window is similar to those of other Microsoft Office applications.

Choosing File, Print or pressing Ctrl+P opens a simplified version of the Office Print dialog box, which offers Print Page Range and Copies settings only. Click Print to print the form.

Closing the Form

To close the current form but leave InfoPath open in startup mode with the working area empty, choose File, Close. To close the form and InfoPath at the same time, choose File, Exit.

Exploring XML Data Documents

The Status Report form s XML data document is much larger and more complex than the simple Contacts.xml file you opened in the section Saving Data as XML Files, in Chapter 1. Status Report data documents have many more elements than Contacts.xml, and the form you completed in the preceding sections includes elements that contain XHTML-formatted data and a picture. The Status Report form doesn t have controls bound to most XML elements that are specified by the document s schema. A few other sample forms add values to elements that Status Report doesn t use.

Modifying Data Documents for Display in Internet Explorer

You can view InfoPath data documents in Notepad and, with a minor modification to the file, in Internet Explorer. Internet Explorer s built-in Extensible Stylesheet Language Transformations (XSLT) document for XML files formats the InfoPath document as HTML for easier reading.


On the CD
If you ve installed the sample files from the CD that accompanies this book, you can skip the following steps and open the C:Microsoft PressIntroducing InfoPath 2003Chapter02 SR6789-1 for IE.xml in Internet Explorer.

To open SR6789-1.xml in Notepad and modify it to create a copy that you can open in Internet Explorer, follow these steps

Modify a document for display in Internet Explorer

  1. In Windows Explorer, navigate to the location where you saved SR6789-1.xml, right-click the file item, and choose Open With, Notepad. If Notepad doesn t appear on the Open With menu, click Choose Program to display the Open With dialog box, click Notepad in the Program list, and click OK. (Don t select the Always Use The Selected Program To Open This Kind Of File check box.)
  2. If text extends past the right edge of Notepad s window, choose Format, Word Wrap to turn on wordwrap .
  3. Select the < ?mso-application progid="InfoPath.Document"? > element, as shown here, which causes the document to open in InfoPath, and press Delete to remove it. (Be careful not to delete more or less than this element.)

    click to expand

  4. Choose File, Save As to open the Save As dialog box, and change the file name to SR6789-1 for IE.xml.
  5. Select All Files in the Files Of Type list. (If you don t do this, Notepad appends .txt to the file name.)
  6. If UTF-8 isn t specified in the Encoding list, select it.
  7. Click Save to save the copy and close Notepad.

Viewing the Status Report Document in Internet Explorer

Follow these steps to view elements to which you assigned values earlier in the chapter:

View Status Report in Internet Explorer

  1. In Windows Explorer, double-click SR6789-1 for IE.xml to open it in Internet Explorer.
  2. If the document opens in an application other than Internet Explorer, close the application, right-click the file name, and choose Open With, Internet Explorer.
  3. Scroll down to display the < sr:date ... > and < sr:employee > elements. sr: is the XML namespace prefix for the Status Report form. Most elements are empty, as shown on the next page.

    click to expand

  4. Continue to scroll until the < sr:billingCode > element is at the top of the Internet Explorer window. The < sr:summary > element bound to the Summary rich text box control contains XHTML-formatted text, as shown here:

    click to expand

  5. Continue scrolling past the < sr:lastPeriod > and < sr:thisPeriod > bulleted lists, which also contain XHTML-formatted text, to the < sr:notes > element and its tables.
  6. Scroll down until you reach the < img ... > element for the picture control you added to the Notes rich text box. The xd:inline= R0lGODlhvQDAAH ... attribute, shown here, contains the data to generate the picture s bitmap. The data is encoded in base64 format , which is required to include binary data in an XML document. The Incorporating Pictures section of Chapter 6 explains how base64 encoding works.

    click to expand

  7. Scroll to the right to see how many characters (5,784) are required to encode the small bitmap. You might need to click the encoded data a few times to make all of it visible as you scroll.
  8. Finally, scroll past the < timeReport > and < budgetReport > elements to the end of the file. Notice that there s no optional < taskList > element, unless you added one, and then close Internet Explorer.

Examining the XML data document for a relatively complex form demonstrates InfoPath s data capture prowess. The procedure also gives you an indication of the verbosity of the XML format ”the size of SR6789-1.xml is 15,722 bytes. The no-frills version of SR6789-1.xml that you use in the next section doesn t have a bitmap or a table but weighs in at 5,487 bytes to deliver 900 bytes of data, which includes XHTML formatting tags. Eliminating the XHTML tags reduces the data size to 559 bytes ”approximately 10 percent of the XML document s total size. However, XML continues to thrive as a data interchange format despite its substantial overhead.


Conducting business electronically with XML
Automating business transactions by exchanging XML documents, such as purchase orders, shipping notices, and invoices, is becoming a common practice. Electronic Business XML (ebXML) is an example of a standard XML vocabulary for global e- business information exchange. The tag overhead of XML documents hasn t been and won t be a barrier to XML s widespread adoption. The benefits of an open-standard, self-describing messaging format far outweigh the size penalty of XML tag bloat. For more information about ebXML, visit .

Merging Forms

Another unique InfoPath feature is the ability to merge multiple forms into a single summary form. As an example, a manager might want to see a summary of all status reports for a single project with total time consumed and funds expended to date. The form merging process is simple; even managers can merge forms without help desk assistance.

Following are the basic requirements and characteristics of the form merging process:

  • The forms you merge must have been created with the same template.
  • The form s template must enable merging; merging is enabled by default.
  • Data in repeating fields, such as repeating sections or tables, is added at the bottom of the first form s corresponding sections or tables.
  • Data in plain, bulleted, and numbered lists is added at the bottom of the corresponding list.
  • Merging adds a separator line to rich text boxes and then adds the data from the merged form below the separator.
  • Data in text boxes that aren t contained in repeating form elements doesn t merge. If you merge multiple forms into an empty form, text boxes in nonrepeating elements are empty.
  • Date picker controls that aren t incorporated in repeating sections display the date of the initial form, not that of the latest merged form. Hopefully, this oversight will be corrected in a future InfoPath version.
  • Custom merge operations let you alter the merging process with programming code.

The Status Report form uses a custom merge operation that adds the value of the Name element to identify merged elements in rich text boxes and doesn t add separator lines between the XHTML content of merged forms.


Merging forms with the sample files
The sample files in your C:Microsoft PressIntroducing InfoPath 2003Chapter02 folder include SR6789-2.xml, a file intended for demonstrating merging with SR6789-1.xml, which is included in this folder. You can merge SR6789-2.xml with the SR6789-1.xml file you created earlier in this chapter or from the sample files folder.

To give the merge process a test drive with two Status Report forms, follow these steps.

Test the merge process

  1. With the SR6789-1.xml file open in InfoPath, choose File, Merge Forms to open the Merge Forms dialog box.
  2. Navigate to the C:Microsoft PressIntroducing InfoPath 2003Chapter02 folder, and select SR6789-2.xml, as shown here:

    click to expand

  3. Click Merge to close the dialog box and complete the merging process.
  4. Choose File, Save As, and save the merged form as SR6789-1 & 2.xml.

Figure 2-17 shows the Summary rich text box and two of the bulleted lists with elements added from the merged forms.

click to expand
Figure 2-17: The merged form s content adds to the Summary rich text box, and Last Period and This Period lists.

Figure 2-18 shows additions to the Time Report and Budget Report repeating tables. It s clear from the merged Budget Report values that Amount Budgeted values should represent a budget detail amount, not the total budget for the project. The merged form adds the Task List item, which wasn t present in SR6789-1.xml.

click to expand
Figure 2-18: Merging Status Report forms totals the Time Report and Budget Report summary values.


InfoPath 2003 provides an Office-standard UI to make entering data into forms a familiar process for Office users. InfoPath offers many data entry featuressuch as date picker controls, optional sections, and repeating tablesthat arent available in ordinary HTML-based forms. Rich text boxes let you add formatted text; tables; plain, bulleted, or numbered lists; and pictures as unstructured XHTML data to rich text boxes.

InfoPath validates data against the forms XML schema and rules that the forms designer applies to individual controls. Data validation reduces the risk of errors resulting from incomplete forms or invalid data.

Saving and printing forms follows the Office model closely. Exploring the saved XML data document gives you insight into the relationship between the documents elements and the forms control values. Merging forms, which is one of InfoPaths most powerful features, combines data from rich text boxes and repeating sections or tables of multiple forms that are based on the same InfoPath template.



Can I work on multiple forms at one time?

certainly. infopath supports working on many different forms at one time, each of which can be opened in one of the different infopath modes. you can open a form in data entry, design, and programming modes simultaneously; each mode has its own window.


Don t rich text boxes that contain a variety of objects not defined in the form s schema conflict with the goal of creating semi-structured, self-describing XML documents?

not necessarily. some widely used xml specifications permit unstructured xhtml content in optional elements. an example is the really simple syndication (rss) 2.0 format, which you ll learn about in chapter 4 . in general, use rich text boxes sparingly and only when the applications that consume your data documents specifically support xhtml.


Can I save a form that has validation errors?

yes, but you won t be able to submit the form to a database or web service, merge it with another form, or digitally sign it.


Can I save an InfoPath data document to a network share so that others can use it?

absolutely. saving a form s data document is just like saving any other type of office system file or document. when the save as dialog box opens, navigate to the network share, and save the .xml file there. alternatively, use windows explorer to copy the .xml file from your disk to the network share.


Do other users need the template to open data documents created from it?

yes. users need network access to or a local copy of the template (.xsn) file to open or edit the document. you set up templates for shared access by publishing them to a server share. ( chapter 12 , publishing form templates, describes the publishing process.) a copied template must be in a folder with exactly the same path as the original template, such as c:program filesinfopath templatename  templatename .xsn. in most cases, copying a template to a subfolder of another user s my documents folder won t work because individual users my documents paths differ. unmodified infopath sample forms are an exception; all infopath users have these templates if they chose a full infopath installation. the sample templates are called fully trusted forms and use registry entries to specify the templates location. chapter 12 shows you how to deliver fully trusted forms to infopath users.



Certainly. InfoPath supports working on many different forms at one time, each of which can be opened in one of the different InfoPath modes. You can open a form in data entry, design, and programming modes simultaneously ; each mode has its own window.


Not necessarily . Some widely used XML specifications permit unstructured XHTML content in optional elements. An example is the Really Simple Syndication (RSS) 2.0 format, which you ll learn about in Chapter 4. In general, use rich text boxes sparingly and only when the applications that consume your data documents specifically support XHTML.


Yes, but you won t be able to submit the form to a database or Web service, merge it with another form, or digitally sign it.


Absolutely. Saving a form s data document is just like saving any other type of Office System file or document. When the Save As dialog box opens, navigate to the network share, and save the .xml file there. Alternatively, use Windows Explorer to copy the .xml file from your disk to the network share.


Yes. Users need network access to or a local copy of the template (.xsn) file to open or edit the document. You set up templates for shared access by publishing them to a server share. (Chapter 12, Publishing Form Templates, describes the publishing process.) A copied template must be in a folder with exactly the same path as the original template, such as C:Program FilesInfoPath TemplateName TemplateName .xsn. In most cases, copying a template to a subfolder of another user s My Documents folder won t work because individual users My Documents paths differ . Unmodified InfoPath sample forms are an exception; all InfoPath users have these templates if they chose a full InfoPath installation. The sample templates are called fully trusted forms and use registry entries to specify the templates location. Chapter 12 shows you how to deliver fully trusted forms to InfoPath users.

On Your Own

Heres an additional exercise for opening an InfoPath sample form, completing it, changing form views, and then merging it with another form:

  1. Start InfoPath, and open the sample Resume form.
  2. Fill in some test data, and then save the form to My DocumentsInfoPath ResumeResume1.xml.
  3. Use the View menu to switch between different views of the Resume1 form.
  4. Use the Fill Out A Form task pane to complete a new sample Resume form.
  5. Add different test data, and then save the form as Resume2.xml in the same folder.
  6. Open Resume1.xml, and merge it with Resume2.xml.
  7. Examine the results of the merge, and optionally , save the merged form as Resume1&2.xml.
  8. Exit InfoPath.

Introducing Microsoft Office InfoPath
Introducing Microsoft Office InfoPath 2003 (Bpg-Other)
ISBN: 0735619522
EAN: 2147483647
Year: 2006
Pages: 248 © 2008-2020.
If you may any questions please contact us: