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.
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
InfoPath loads the StatusReport.xsn template, and creates an empty Form1 XML data document in memory. Now you re ready to begin entering data.
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.
Figure 2-1: You can use the date picker control to postdate a report.
Text boxes are InfoPath s most widely used control. Following are the most important data entry characteristics of text boxes:
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.
Note |
Entering sample text in all fields is important |
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
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.
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).
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.
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
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.
Note |
Displaying formatting shortcut keys |
The following two procedures demonstrate the character and paragraph formatting capabilities of the rich text box s XHTML editor.
Format text characters
Format paragraphs
At this point, your Summary rich text box should appear similar to that shown in Figure 2-6.
Figure 2-6: Your Summary rich text box should now contain formatted text and paragraphs similar to those shown here.
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:
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.
Figure 2-7: This Status Report document has three bulleted lists with deleted, added, and formatted items.
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
Note |
SP-1 Drawing tables |
At this point, your added table appears as shown in Figure 2-8.
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
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.
Figure 2-9: This table is the modified version of the table from Figure 2-6.
Modify table borders and shading
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. |
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.
Figure 2-10: You can paste tables you copy from Word, Access, and Excel into a rich text box.
Note |
Separating rich text data with horizontal lines |
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.
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.
Figure 2-12: You use the shortcut menu to navigate to the Web site specified by the hyperlink control.
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.
Note |
Placing images in tables |
Add a picture from a local file
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
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.
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
The optional section s shortcut menu and shortcut keys do the following:
Following are the actions you can take with the repeating table s shortcut menu and shortcut keys:
Note |
Sorting a repeating table s rows |
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.
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.
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:
Note |
Comparing schema conformance and validation rule compliance |
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
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.
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 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.
Note |
Looking for the File, Properties dialog box? |
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.
Figure 2-15: Save completed sample InfoPath data documents in your My DocumentsInfoPath StatusReport folder.
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.
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.
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.
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.
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.
Note |
On the CD |
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
Follow these steps to view elements to which you assigned values earlier in the chapter:
View Status Report in 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.
Note |
Conducting business electronically with XML |
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 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.
Note |
Merging forms with the sample files |
To give the merge process a test drive with two Status Report forms, follow these steps.
Test the merge process
Figure 2-17 shows the Summary rich text box and two of the bulleted lists with elements added from the merged forms.
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.
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.
1. |
Can I work on multiple forms at one time? |
|
2. |
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? |
|
3. |
Can I save a form that has validation errors? |
|
4. |
Can I save an InfoPath data document to a network share so that others can use it? |
|
5. |
Do other users need the template to open data documents created from it? |
Answers
1. |
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. |
2. |
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. |
3. |
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. |
4. |
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. |
5. |
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. |
Heres an additional exercise for opening an InfoPath sample form, completing it, changing form views, and then merging it with another form:
Part I - Introducing Microsoft Office InfoPath 2003 SP-1
Part II - Designing InfoPath Forms
Part III - Working with Databases and Web Services
Part IV - Programming InfoPath Forms