Chapter 18: Working with Queries and Record Sources

 

There are two places in the application where you can create queries; the Queries item in the Project Pane, and the Record Source View of a report or label.

 

Queries created using the Queries item can be used throughout your project file; that is, they can be referenced from within any report or label in your project.

 

Queries created on the Record Source View of a report or label can only be used from within that specific report or label.

 

A query allows you to limit the amount of data retrieved by a report or label. For example, you could have a table containing hundreds of rows of sales data, but only require those rows that relate to a specific sales person. By using a query you can filter the table’s data so that only those rows that relate to the specific sales person is used in the report or label.

 

Queries that you create using the Queries item will be placed as sub-items to the Queries item in the Project Pane.  Note that a red flag beside a query item ( icon_query_invalid ) indicates that the query contains an error and cannot be run.

 

Note that the sample project Chapter18_Queries.pnj contains a query called Query2 that is used as the basis of this section. You can access this project by clicking File – Open Project in the application menu, then enabling the Open a sample project option.