Using a dynamic filter (Video - 5:36) Follow


BarTender Content Team

Applies to: BarTender 2016 and higher
This video/article uses the following downloads:


When you need the ability to provide filter criteria at print-time, you can use the Database Connection Setup dialog to create a query prompt that appears each time the document is printed, allowing the user to enter criteria for a database search. Only records that match the entered text will be printed.

Query prompts are useful when you want the print operator to be able to print specific filtered records "on the fly." For example, suppose you run a shipping company where you want to give the print operator the ability to print shipping labels based on the city of the recipient. To do this, you would use the Filter property page of the Database Setup dialog to create a filter condition where the "City" field from the database equals a query prompt. At print-time, a query prompt dialog is then displayed, allowing the print operator to enter the city name. Only records containing City fields that equal the name of the entered city will be printed.

For more information on filters and query prompts please review the following resources:

Using a basic filter

Filtering Data

Filtering Data Using a Query Prompt


Creating a dynamic filter

If you aren't familiar with filtering data in BarTender, then you will want to review the support articles Introduction to selecting records and  Using a basic filter.


  1. Place Sample.xlsx in C:\Database Filter\
  2. Create a new BarTender document and create a database connection to Sample.xlsx.  Please review Getting started with database connections for help creating the database connection.
  3. Click File > Database Connection Setup
  4. Select Filter
  5. You should now see all the data since a filter has not been added yet
  6. Click the   icon to add a filter condition
  7. Click   to enable the drop-down menu option
  8. Click  and select New Query Prompt.. 
  9. For the purpose of this example, leave the default settings and click OK
  10. Click Ok to close Database Setup
  11. Remember to save your label


Testing the Query Prompt

You should test your Query Prompt to make sure you get the expected results.

  1. Click File > Database Connection Setup
  2. Click Filter
  3. Click Apply Filter
  4. The Query Prompt should pop up.  Enter Seattle and click OK
  5. You should get all the Seattle records
  6. If you want to see all records you can click Apply Filter again, and then click Cancel
  7. Click OK to close Database Setup
  8. Add three single-line text objects and set the datasources to the each of the database fields: City, Distributor, and Part Number
  9. Your label should look similar to this
  10. Click File > Print Preview
  11. Enter Munich in the Query Prompt
  12. You should have four labels in your print preview


Selecting records to print after Query Prompt

You can use the Query Prompt as a filter, and choose specific records to print after the filter records are returned.

  1. Click File > Print
  2. Set Queried Records to Selected at Print Time
  3. Click Print Preview
  4. Enter Munich in the Query Prompt, then click Next
  5. You can now choose which of the Munich records to print.  Uncheck the boxes next to records 3 and 4.
  6. Click Preview
  7. Now you should only have two labels in your print preview


Link query to a form control

A query can be linked to any form control.  Linking a query to a form control is the same process regardless of which form control type is used.  This example will show how to link a query to a text input box.

  1. Add a Text Input Box to the form
  2. Expand Query Prompts in the Data Sources toolbox and drag QueryPrompt1 onto the Text Input Box

  3. Open the Text Input Box Properties (Right click > Properties) and select Text Label on the left.  Change the text from Enter Data: to Enter City:

  4. Click Close to close the Text Input Box Properties
  5. You have now linked your query prompt to a text input box on your data entry form
  6. Click File > Print Preview
  7. Enter Seattle
  8. All Seattle records are printed


Do you have feedback or questions on this article? We encourage you to post them on our Community Forums