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.

Examples

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.

ClosedSetting Up Your Document for Use with the Examples

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
0543166
17890
1203768
1029384
98563
467233

Product
Oranges
Flower Pot
Apples
Bananas
Glass Globe
Shovel

Type
Perishable
Breakable
Perishable
Perishable
Breakable
Tool

The examples also require you to perform the following procedures.

ClosedLink objects on your template to database fields

  1. 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.

  2. Click the template at the location where you want to place the object.

  3. On the Data Sources pane of the Toolbox, expand the Database Fields node.

  4. Drag the ID field to the text object to link the object to the data source.

  5. Repeat steps 1 and 2 to create a new text object.

  6. 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.

  7. Repeat steps 1 and 2 to create a new text object.

  8. 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.

ClosedCreate a query prompt for the Type field

  1. 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.)

  2. In the navigation pane of the Database Setup dialog, click Filter to open the Filter property page.

  3. Click to create a new filter condition.

  4. Click the [Data Source], and then click the Type database field in the list.

  5. Click the [Operator], and then click Equals.

  6. Click <enter a value>, and then click New Query Prompt in the list to open the Query Prompts dialog.

  7. 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.

  8. Click OK to close the Query Prompts dialog.

  9. Click Apply Filter to apply your filter and see the results. The query prompt prompts you for input.

  10. Click OK to close the Database Setup dialog.

If you stop here, BarTender displays a dialog at the beginning of your print job that asks you to filter (or "query") the records that you want to print. When you enter a type, such as "Breakable," BarTender prints only those records that match (in this example, the "Flower Pot" and "Glass Globe" products).

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.

ClosedExample 1: Connecting a Query Prompt to a Radio Button List Control

  1. Open the form where you want to place the query prompt.

  2. 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.

  3. Click the form at the location where you want to place the control.

  4. Double-click the control to open the Radio Button List Properties dialog. Alternatively, click Properties on the control's context menu.

  5. In the navigation pane, click Linked Data Source to open the Linked Data Source property page.

  6. In the list of data sources, expand the Query Prompts node, and then select the Type query prompt.

  7. In the navigation pane, click List Items to open the List Items property page.

  8. 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.

  9. Configure the other properties of the control by using the other property pages.

  10. 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.

  11. 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.

When you click one of the radio buttons on the form, BarTender prints only those records that have the type that matches your selection.

ClosedExample 2: Connecting a Query Prompt to a Check Box Control

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.

  1. Open the form where you want to place the query prompt.

  2. 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.

  3. Click the form at the location where you want to place the control.

  4. Double-click the control to open the Check Box Properties dialog. Alternatively, click Properties on the control's context menu.

  5. In the navigation pane, click Linked Data Source to open the Linked Data Source property page.

  6. In the list of data sources, expand the Query Prompts node, and then select the Type query prompt.

  7. In the navigation pane, click Check Box to open the Check Box property page.

  8. In the Display Text field, enter Perishable.

  9. Verify that the Use the Display Text for the Checked Value option is selected.

  10. In the Unchecked Value field, enter Tool.

  11. Click Close to close the Check Box Properties dialog.

  12. Click on the main toolbar to preview your data entry form.

ClosedExample 3: Connecting a Query Prompt to a Text Input Box Control

  1. Open the form where you want to place the query prompt.

  2. 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.

  3. Click the form at the location where you want to place the control.

  4. Double-click the control to open the Text Input Box Properties dialog. Alternatively, click Properties on the control's context menu.

  5. In the navigation pane, click Linked Data Source to open the Linked Data Source property page.

  6. In the list of data sources, expand the Query Prompts node, and then select the Type query prompt.

  7. In the navigation pane, click Autocomplete to open the Autocomplete property page.

  8. Click to select the Enable autocomplete check box.

  9. 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.

  10. Click Close to close the Control Properties dialog.

  11. Click on the main toolbar to preview your data entry form.

Related Topics