4.3. Previewing the Form

Now that all the work has been done to create the form, it is time to test the work that you have done. It's a good idea to preview a form before you publish the form for other users. To accomplish this, click the Preview Form toolbar button or choose FilePreview Form.



NOTE

When creating larger forms, test the form as you create major sections. Make sure that the form is looking as you want it when it is to be used in production.

Note that when you make changes to data in Preview mode and submit the data, the data is actually submitted to the database as if you had published the form or opened the form for filling. The reason it is referred to as previewing is because you are viewing it from Design mode rather than from Fill mode.

4.3.1.

4.3.1.1. Try It Out: Querying a Customer Record by Region

The first thing to test when previewing the form is to make sure that the query field is working correctly. To test this feature using the form created in the chapter:

  1. Click the Preview Form toolbar button.

  2. If necessary, scroll down to the Query Fields section.

  3. Type WA in the Region query field.

  4. Click Run Query. The record of the customer who is located in WA is displayed, as shown in Figure 4-15.

4.3.1.2. How It Works

When the Region field was added from the queryFields branch in the data source tree view to the Query Field section, InfoPath then knows that you are intending to use that field to query the database. When you supply a value in the Region field and click the Run Query button, InfoPath creates a select query similar to:

Select tblCustomers.CustomerID, tblCustomers.Company,... From tblCustomers Where Region = "BC"

The query is then submitted to the connected database. XML is generated in the form of records matching the criteria that are then populated into the fields and displayed in the form. If no records match, a message box is displayed notifying you of the fact that there are no records.

Figure 4.15. Figure 4-15

4.3.1.3. Try It Out: Modify a Customer's Record

Using the customer record that was retrieved in the last Try It Out:

  1. Modify one of the fields in the record.

  2. Choose FileSubmit, or click on the Submit toolbar button. The data is then updated to the database.

4.3.1.4. How It Works

When the Submit button is clicked after the information in the field has been updated, an UPDATE SQL statement is generated, with the data updated back in tables in the database specified in the data connection.

4.3.1.5. Try It Out: Adding a New Customer

With the form used in the last Try It Out:

  1. Click the New Record button. The fields are then cleared in the form, as shown in Figure 4-16. Notice that the query field has not been cleared.

    Figure 4.16. Figure 4-16
  2. Add the desired data into the fields.

  3. Click the Submit button. The data is then updated in the database.

Notice the arrow below the table displayed in Figure 4-16 with the label Insert Item. This is another way to add a new record to the database, provided by InfoPath, with no additional work to perform on your part.

4.3.1.6. How It Works

After you have adding the information into the fields and clicked the Submit button, an INSERT INTO SQL statement is generated and the information inserted into the tables in the database that was specified by the data connection.

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

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