Adding a Query Prompt to the Form |
A query prompt enables users to enter criteria to filter database records at print-time. After it is defined in the Filter view of the Database Setup dialog, the query 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. Linking a query prompt to a control on your form enables users to 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, ensuring the correct records are available for printing or for driving further form functionality.
The examples in this section are meant to help you become familiar with the basic steps for using query prompts on your data entry form. To complete the examples, you will first need to connect to a simple database, create three text objects in your template, and create a query prompt for the connected database.
The following examples require that you connect to a database with a table that contains products, where each product is one of three specific types, such as that shown below.
ID |
Product |
Type |
The examples also assume that you have done the following:
Link objects on your template to database fields
From the Create menu of the Template Design view, click Text, and then select Single Line. Alternatively, click the icon on the object toolbar, and then select Single Line.
Click the template to place the object at the cursor location.
On the Data Sources pane of the Toolbox, expand the Database Fields node.
Click on and drag the ID field to the text object, linking 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, click on and drag the Product field to the new text object, linking 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, click on and drag the Type field to the new text object, linking the object to the data source.
Create a query prompt for the Type field
From the File menu, select 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, this step will launch the Database Setup Wizard. Complete the wizard to display the Database Setup dialog.
From the Navigation Pane of the Database Setup dialog, select Filter to open the Filter property page.
Click to create a new filter condition.
Click the [Data Source] and select the Type database field from the list.
Click the [Operator] to select Equals.
Click <enter a value> and select New Query Prompt 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 use the query prompt in conjunction with a control, the options are set 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 will ask 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. Once you do 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.
From the Create menu, click Data Entry Control, and then select Radio Button List. Alternatively, click the icon on the object toolbar and select Radio Button List.
Click the form to place the control at the cursor location.
Double-click the control to open the Radio Button List Properties dialog. Alternatively, select Properties from the control's context menu.
From the Navigation Pane, select Linked Data Source to open the Linked Data Source property page.
From the list of data sources, expand the Query Prompts node, and then select the Type query prompt.
From the Navigation Pane, select List Items to open the List Items property page.
If not already specified, select Query Prompt Values for the Source. Note that the values shown for the Display Text and Item Value properties reflect the values of the database Type field.
Configure other properties of the control by using the provided property pages.
Click Close to close the Radio Button List Properties dialog. Note that the radio button list now 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 will not affect what is actually printed on your items. |
|
Ideally, for a check box control, the database table would 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 enabled, the "Perishable" records will print on the item. When it is not checked, then the "Tool" records will print. |
Open the form where you want to place the query prompt.
From the Create menu, click Data Entry Control, and then select Check Box. Alternatively, click the icon on the object toolbar, and then select Check Box.
Click the form to place the control at the cursor location.
Double-click the control to open the Check Box Properties dialog. Alternatively, select Properties from the control's context menu.
From the Navigation Pane, select Linked Data Source to open the Linked Data Source property page.
From the list of data sources, expand the Query Prompts node, and then select the Type query prompt.
From the Navigation Pane, select Check Box to open the Check Box property page.
For Display Text, type Perishable.
Ensure that Use the Display Text for the Checked Value is checked.
For Unchecked Value, type 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.
From the Create menu, click Data Entry Control, and then select Text Input Box. Alternatively, click the icon on the object toolbar and select Text Input Box.
Click the form to place the control at the cursor location.
Double-click the control to open the Text Input Box Properties dialog. Alternatively, select Properties from the control's context menu.
From the Navigation Pane, select Linked Data Source to open the Linked Data Source property page.
From the list of data sources, expand the Query Prompts node, and then select the Type query prompt.
From the Navigation Pane, select Autocomplete to open the Autocomplete property page.
Check Enable autocomplete.
From the Source dropdown list, select Query Prompt Values. Note that the values shown for the Autocomplete Suggestions reflect the values in the database field "Type".
Click Close to close the Control Properties dialog.
Click on the main toolbar to preview your data entry form.
Related Topics