Getting Started with Microsoft InfoPath 2003by Wei-Meng Lee, author of Windows XP Unwired
One of the things I have always been averse to doing is filling out forms. This is especially troublesome if you work in a big company where you have to fill out multiple forms just to purchase an item. Most of you have had this similar experience: first you have to fill out a physical form to get your superior's approval for an item, then you must fill out an online requisition order to procure the item. Wouldn't it be nice if you could simply fill out one form that would allow all other applications to use the data collected on that form?
Microsoft has realized this problem and presents its solution in InfoPath 2003, an application that comes with Microsoft Office 2003 Professional Edition. InfoPath 2003 allows you to build forms for data collection and then save them in the XML document format. With XML, different applications can then reuse the information without the need for users to enter the same data multiple times.
In this article, I will introduce you to the power of InfoPath 2003 and show you how you can build a simple form to start collecting data.
Examining the XML Schema
InfoPath 2003 provides several ways for you to define the types of data you want to collect:
- XML Schema or XML document
- Web services
For this article, I will illustrate the first method--using an XML Schema. Suppose I have the following XSD document:
<?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="Magazines" type="MagazineType"/> <xsd:complexType name="MagazineType"> <xsd:sequence> <xsd:element name="Magazine" type="MagazineDetails" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="MagazineDetails"> <xsd:sequence> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/> <xsd:element name="Comments" type="xsd:string" minOccurs="0" maxOccurs="1"/> </xsd:sequence> <xsd:attribute name="Price" type="xsd:float"/> </xsd:complexType> </xsd:schema>
This XSD defines the structure of the information that I want to collect. In particular, I want to capture magazine information such as title, price, and publisher.
Building and Designing the Form
Using the XSD document, I want to build a form to collect information about the magazines that I have. So, let's launch InfoPath 2003 and go to File -> Design a Form.
You will see the Task Pane displayed on the right side of the window (see Figure 1):
Figure 1. Designing a new form
You can create a new form from a Data source (such as from a schema, a database, or a Web service), and then either start a blank form, or extend a sample form (provided by InfoPath 2003). For this example, I want to create a new form from an XSD document, and so I select "New From Data Source".
In the Data Source Setup Wizard (see Figure 2), select the type of data source to which you are connecting. In my case, select XML Schema or XML data file. Click Next.
Figure 2. Selecting the data source
Browse for the XML Schema and click Finish.
In the Task Pane, you will be able to see the element and attribute names as defined in the XSD (see Figure 3).
Figure 3. Viewing the data source
To build the form for the user to fill in, click on Layout in the Task Pane and use the required layout controls.
First, let's add a "Table with Title" to our form (see Figure 4). I have also changed the shading and font color.
Then, click on Data Source in the Task Pane, and drag the Magazine folder into the Table (see Figure 5):
You will be prompted to select the kind of section you want to add. Select Repeating Table (see Figure 6):
Figure 6. Choosing the Repeating Table
You should see the layout, as shown in Figure 7:
Figure 7. The newly created form layout
You are now ready to publish the form.
Publishing the Form
To publish the form, go to File - > Publish.
The Publishing Wizard provides three ways to publish your form (see Figure 8):
Figure 8. Choosing the way to publish a form
In my case, I chose to publish it to a shared folder, c:\Magazine.xsn.
To use the form, the user simply needs to double-click on the .xsn file (in Windows Explorer) and InfoPath will launch the form. (In an Intranet setting, it would be useful to publish the form to a Web server and point the user to the URL to download the form.)
You can enter multiple magazine information by clicking on the arrow and selecting Insert Magazine above/below to add new records (see Figure 9):
Figure 9. Filling in the form
Once you've completed entering the data, you need to save the form. To save it, simply click on File - > Save. All the magazine information will be saved in an XML document.
You can use NotePad to view the XML document you've generated:
<?xml version="1.0" encoding="UTF-8"?> <?mso-infoPathSolution solutionVersion="126.96.36.199" productVersion="11.0.5531" PIVersion="188.8.131.52" href="file:///C:\Magazine.xsn" language="en-us" ?> <?mso-application progid="InfoPath.Document"?> <Magazines> <Magazine Price="5.95"> <Title>SQL Server magazine</Title> <Publisher>Penton</Publisher> <Comments></Comments> </Magazine> <Magazine Price="4.95"> <Title>Web Techniques</Title> <Publisher>CMP</Publisher> <Comments>Renamed to ...</Comments> </Magazine> <Magazine Price="5.00"> <Title>Wireless and B</Title> <Publisher>Sys-Con Media</Publisher> <Comments></Comments> </Magazine> </Magazines>
Note that the XML document has two additional PIs (Processing Instructions) to invoke InfoPath 2003 when it is double clicked.
Since the information is now saved as XML, other applications can then easily use the information in the document.
Printing the Form
Besides filling in the form and saving the data as XML, InfoPath 2003 also allows you to print the form. This is especially useful when you need to generate a hard copy of your form to sign. You can preview the form by going to File - > Print Preview (see Figure 10):
InfoPath 2003 is a useful tool for collecting data, especially in organizations where there is a need to integrate several applications together. In this article, you have seen how InfoPath 2003 works and how to build a very simple form to collect data and save it as an XML document. If you have any questions, feel free to use the TalkBack section below to send them to me.
Wei-Meng Lee (Microsoft MVP) http://weimenglee.blogspot.com is a technologist and founder of Developer Learning Solutions http://www.developerlearningsolutions.com, a technology company specializing in hands-on training on the latest Microsoft technologies.
Return to the Web Development DevCenter.
How can I learn about creating web services for a database that infopath doesn't natively support?
2009-03-02 09:12:12 larryvirden [View]
I WANT TO DESIGN A FORM FOR USERS AT VARIOUS PLACES ACROSS MY INTRANET
2008-02-26 06:24:55 CHITTA [View]
2007-06-18 10:44:32 ssierschula [View]
2007-06-18 10:44:02 ssierschula [View]
2007-06-18 10:43:57 ssierschula [View]
2005-02-10 15:57:21 Medde [View]
2004-02-25 03:45:37 phrenetic [View]
2004-05-12 14:39:34 bazango [View]
2004-01-07 06:36:52 rhinoguy23 [View]
2004-02-04 06:57:29 travisowens [View]