4.2. Working with the Created InfoPath Form

Before continuing with completing the InfoPath form, it is worthwhile to take a look at the various features created by default on the form and in the designer.

4.2.1. A Look at the Features of the New Form

Working with the callouts in Figure 4-8, the following list details different features of the new form created:

  • Form Header: This section is a layout table with the type of Table with Title. It is used as the header for the form.

  • Data Source Task Pane: This task pane displays the main data source for the InfoPath form. It includes fields used for both the query and data sections of the form.

  • Query Field Section: To limit the data brought down over the network, be it local area network or Internet, fields can be assigned for querying data. When fields are assigned to the Query Field section, they may or may not be used for querying, and the records returned from the query supplied to the form used for display or modification.

  • Query Field Section: To limit the data brought down over the network, be it local area network or Internet, fields can be assigned for querying data. When fields are assigned to the Query Field section, they may or may not be supplied, and records displayed in the form for modifications if specified.

  • Data Field Section: This section contains the data fields used on the form. Data fields are used to display, modify, or append data.

Once data has been updated or added to the Data Field section, the user will click the Submit toolbar button. An alternative is to choose Submit from the File menu. The data is then submitted into the database.

  • New Record Command Button: Once this button is clicked, blank fields are displayed ready for adding new data. Click submit to append the record to the database.

  • Run Query Command Button: After query fields are filled in and this button clicked, a query is sent to the connected database, and data is returned matching the query for use in the InfoPath form.

The remaining sections of this chapter cover each of the features displayed in the prior list. Before moving on to the more interesting features, complete the following Try It Out, specifying the header for the form.

4.2.1.1. Try It Out: Filling in the Form Header Information

Using the form created in the last Try It Out:

  1. Click in the Header section, in the area labeled Click to add a title.

  2. Type Customer Information. The header will look as it does in Figure 4-9.

    Figure 4.9. Figure 4-9

The bottom half of the section will not be used for this example.

4.2.2. Data Source Task Pane

The Data Source task pane contains the data sources specified using the Data Connection Wizard. In the initial form as created in the last Try It Out, data sources (tables, queries, and fields) are displayed for queryFields and dataFields using a tree view style display.

Clicking a node in the tree view displayed in the data sources task pane expands the next level of the data source.

4.2.2.1. Try It Out: Displaying the Fields in the Data Source

Continuing with the form used in the last Try It Out:

  1. Click the plus (+) symbol by the queryFields description. The tree node with the label q:tblCustomers is displayed.

  2. Click the plus (+) symbol by the q:tblCustomers tree node. The fields you designated to be included from the table are displayed.

  3. Perform Steps 1 and 2 for the dataFields node in the tree view to display the fields used in the Data Fields section of the form. The tree view then looks as it does in Figure 4-10.

    Figure 4.10. Figure 4-10

There are a number of other features within the Data Source task pane that you will use throughout the rest of this book. The Data Source task pane and its elements are now set up for use with the rest of the chapter, starting in the next section.

As you drag any of the fields onto the form, InfoPath will create a control for you, based on the type of the data. For example, if you drag a field onto the form that is a Date data type, then InfoPath creates a Date Picker type control for you, bound to the field in the data source. Controls also can be placed upon the form and then bound to a field in the data source.

The default control type created is Text Box. This includes controls dragged into the Query Field section.

4.2.3. Query Field Section

The Query Field section is used to specify fields that can be used to query data in the connected database. An example of this is adding the City field onto the Query Field section. When the form is opened, the user can supply a city such as Seattle and InfoPath returns the records where the data in the City field matches Seattle.

4.2.3.1. Adding the fields

To add a query field a field is highlighted in the queryFields node of the data source tree. Holding down the left mouse button, the field is dragged over onto the Query Field section of the form. Besides a text box control being created, a label with the field's Caption property is created.

4.2.3.2. Try It Out: Adding Fields to the Query Field Section

Using the form created in this chapter, as displayed in the last Try It Out:

  1. Click on the Region field located in the queryFields q:tblCustomers node of the data source tree view control.

  2. Drag and drop the Region field into the Query Fields section of the form. The section then look as shown in Figure 4-11, with the Run Query button included.

    Figure 4.11. Figure 4-11

You need to supply the fields in the Data Field section before you can see any of the records returned from the database.

Be sure to pull the fields from queryFields tree nodes for the Query Field section. Otherwise, if you use dataFields for the Query Field section an error will be displayed stating "The action will delete all information in the current form." The dataFields fields used in the Data section will display the query data.

4.2.3.3. Using More Than One Query Field

When using more than one field in the Query Field section, InfoPath will "And" the fields when querying the database. What this means is that if you have both City and Country in the Query Field section and both fields are filled in, then records where both fields are equal will be returned. For instance:

  • If you have specified Seattle for the city and Canada for the country, then no records will be returned.

  • If you have specified Vancouver for the city and Canada for the country, then one or more records will be returned.

4.2.4. Data Field Section

Where the Query Field section is for querying the database, the Data Field section is for displaying, updating, and adding the actual data. More choices are necessary when adding the fields to the Data Field section. You can add fields one at a time or add a whole section.

4.2.4.1. Adding Fields One at a Time

When adding fields individually you have more control over how you want to have the fields displayed as you are adding them. Tables can be added to the form for additional formatting of the form. If you are adding fields one at a time, click the field in the dataFields branch of the data source tree view, dragging it to the location where you want it on the form, much as you did with the queryFields. A repeating section is added when you add the first field onto the form. More information about repeating sections is discussed in the next section.

To add the tables when needed, switch to the Layout task pane, and choose the layout table desired, as shown in Chapter 2, "Getting Started Designing with InfoPath."

4.2.4.2. Adding Repeating Sections of Fields to the Form

Another way to add fields is to add complete repeating sections to the form. Repeating sections are analogous to tables or queries, in that you will drag them onto the form to create the section that will display one or more records. When you click the table tblCustomers, you will see the menu displayed in Figure 4-12.

Figure 4.12. Figure 4-12

The following list discusses the available items:

  • Repeating Table: Displays data in a tabular view similar to a datasheet view in Access, or a spreadsheet in Excel. This is a good choice when you expect to have many records returned from the query.

  • Repeating Section with Controls: Creates a repeating section with the fields going down the page rather than across it like the prior choice. A repeating section with controls is recommended when you are only expecting single records to be returned.

  • Repeating Section: The section created from this choice is bound to the section, but contains no controls initially. This is the option to use when you are planning to add the fields singularly.

  • Master/Detail: These sections are used for two related tables, showing a master record such as invoice information, and one-to-many detail records such as the detail records for an invoice.

Remember that whichever choice you use you can modify the sections to match the vision you have in your mind for the form you're creating.

4.2.4.3. Try It Out: Adding Fields to the Data Field Section

This Try It Out continues with the form created earlier in this chapter:

  1. Highlight the d:tblCustomers table in the data source tree view, holding down the left mouse button.

  2. Drag and drop the d:tblCustomers into the Data Fields section. The menu for type of repeating section is displayed.

  3. Click the Repeating Table option.

  4. Adjust the width of the table and fields to show more of the City field, as shown in Figure 4-13.

    Figure 4.13. Figure 4-13

The form is now ready for prime time, or at least for you to preview. Before previewing the form, read the following section about the two command buttons created by default on the form.

4.2.5. New Record and Run Query Command Buttons

The two command buttons added to the form include two of the four built-in commands you can assign to command buttons. To check out the actions of command buttons, right-click and pick Properties. You then see the button properties, as shown in Figure 4-14.

Figure 4.14. Figure 4-14

The four built-in commands are pretty self-explanatory. Run Query, Submit, New Record, and Delete & Submit are all commands that are performed using the current view against the database. Rules and Custom Code enable the developer to create rules or custom code using scripts (or C#) to accomplish custom tasks.

4.2.5.1. Try It Out: Examining to Run Query Command Button Action

Continuing with the form created in this chapter:

  1. Right-click the command button labeled Run Query.

  2. Choose Properties. The Button Properties dialog box opens.

You will see the Run Query action displayed for the action of the command button. More on creating your own command buttons can be found in Chapter 6, "Working with Controls in General."

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.28.107