Adding a Query Prompt to the Form |
By using query prompts, users can enter criteria to filter database records at print time. After you specify the query prompt in the Filter view of the Database Setup dialog, the prompt is available as a data source that can be connected to a control on the data entry form by using the control's Linked Data Source property page.
When you link a query prompt to a control on your form, users can select filter criteria from actual values that exist in the database for the field on which you are filtering the records. This can increase the accuracy of the filter, which ensures that the correct records are available for printing or for driving further form functionality.
Use the examples in this section to become familiar with the basic steps for using query prompts on your data entry form. To complete the examples, first connect to a simple database, create three text objects in your template, and then create a query prompt for the connected database.
The following examples require that you connect to a database that has a table that contains products, where each product is one of three specific types, as follows.
ID |
Product |
Type |
The examples also require you to perform the following procedures.
Link objects on your template to database fields
On the Create menu of the Template Design view, click Text, and then click Normal. Alternatively, click the icon on the object toolbar, and then click Normal.
Click the template at the location where you want to place the object.
On the Data Sources pane of the Toolbox, expand the Database Fields node.
Drag the ID field to the text object to link the object to the data source.
Repeat steps 1 and 2 to create a new text object.
From the expanded Database Fields node on the Data Source pane, drag the Product field to the new text object to link the object to the data source.
Repeat steps 1 and 2 to create a new text object.
From the expanded Database Fields node on the Data Source pane, drag the Type field to the new text object to link the object to the data source.
Create a query prompt for the Type field
On the File menu, click Database Connection Setup to open the Database Setup dialog. Alternatively, click the icon on the main toolbar. (If you have not previously connected to a database, the Database Setup wizard starts. Complete the wizard to display the Database Setup dialog.)
In the navigation pane of the Database Setup dialog, click Filter to open the Filter property page.
Click to create a new filter condition.
Click the [Data Source], and then click the Type database field in the list.
Click the [Operator], and then click Equals.
Click <enter a value>, and then click New Query Prompt in the list to open the Query Prompts dialog.
Name the query prompt "Type". Specifying the additional query prompt options is necessary only if you do not plan to associate the query prompt with a data entry control. If you associate the query prompt with a control, you configure the options by using the control's property pages.
Click OK to close the Query Prompts dialog.
Click Apply Filter to apply your filter and see the results. The query prompt prompts you for input.
Click OK to close the Database Setup dialog.
The following examples demonstrate how to integrate query prompts with data entry controls on a form. After you connect a control to a query prompt, the prompt appears on the form rather than in its own unique dialog.
Open the form where you want to place the query prompt.
On the Create menu, click Data Entry Control, and then click Radio Button List. Alternatively, click the icon on the object toolbar, and then click Radio Button List.
Click the form at the location where you want to place the control.
Double-click the control to open the Radio Button List Properties dialog. Alternatively, click Properties on the control's context menu.
In the navigation pane, click Linked Data Source to open the Linked Data Source property page.
In the list of data sources, expand the Query Prompts node, and then select the Type query prompt.
In the navigation pane, click List Items to open the List Items property page.
In the Source list, click Query Prompt Values if it is not already selected. Note that the values that are displayed for the Display Text and Item Value properties reflect the values of the database Type field.
Configure the other properties of the control by using the other property pages.
Click Close to close the Radio Button List Properties dialog. The radio button list displays a button for each value of the Type database field.
Click on the main toolbar to preview your data entry form.
|
You can modify how the different records appear on the form by changing the display text. This does not affect what is actually printed on your items. |
|
Ideally, for a check box control, the database table should contain only two unique values for the Type field. For this example, assume that there are only two values, "Perishable" and "Tool". When the check box is selected, the "Perishable" records are printed. When the check box is not selected, then the "Tool" records are printed. |
Open the form where you want to place the query prompt.
On the Create menu, click Data Entry Control, and then click Check Box. Alternatively, click the icon on the object toolbar, and then click Check Box.
Click the form at the location where you want to place the control.
Double-click the control to open the Check Box Properties dialog. Alternatively, click Properties on the control's context menu.
In the navigation pane, click Linked Data Source to open the Linked Data Source property page.
In the list of data sources, expand the Query Prompts node, and then select the Type query prompt.
In the navigation pane, click Check Box to open the Check Box property page.
In the Display Text field, enter Perishable.
Verify that the Use the Display Text for the Checked Value option is selected.
In the Unchecked Value field, enter Tool.
Click Close to close the Check Box Properties dialog.
Click on the main toolbar to preview your data entry form.
Open the form where you want to place the query prompt.
On the Create menu, click Data Entry Control, and then click Text Input Box. Alternatively, click the icon on the object toolbar, and then click Text Input Box.
Click the form at the location where you want to place the control.
Double-click the control to open the Text Input Box Properties dialog. Alternatively, click Properties on the control's context menu.
In the navigation pane, click Linked Data Source to open the Linked Data Source property page.
In the list of data sources, expand the Query Prompts node, and then select the Type query prompt.
In the navigation pane, click Autocomplete to open the Autocomplete property page.
Click to select the Enable autocomplete check box.
In the Source list, click Query Prompt Values if it is not already selected. Note that the values that are displayed for the Autocomplete Suggestions reflect the values in the "Type" database field.
Click Close to close the Control Properties dialog.
Click on the main toolbar to preview your data entry form.
Related Topics