Suppression Example |
When retrieving data from a database, BarTender may encounter fields that contain no data. In these cases, you may wish to suppress a data source so that a blank space will not appear on your label.
Consider the following example: a retail company prints a number of shipping labels where the "Ship To" address printed on the labels is retrieved from a central customer database. Some records contain a customer name and company, while others contain only the customer name or only the company name, as in the sample data below:
"CustomerName","CompanyName","Address","City","State","ZIP",
"Jake Diamond","Diamond, Inc.","PO Box 60","Gem Town","NV","50897",
"Meg Reilly","","148 Circle Drive","Maple","WA","98005",
"","All-State Trucking","5601 Interstate","Huntsville","IN","40890"
When saved into a text file, each of these pieces of information can be used as a database field, enabling you to create a generic address template that pulls the information in dynamically.
If you set up your template to have each of these fields print out as separate text objects, your labels would be outputted as follows:
Jake Diamond |
Meg Reilly |
|
Notice how the blank second field in the second record and the blank first field in the third record of the sample data file result in skipped lines on the labels. You can avoid these skipped lines by specifying that:
the entire address be outputted as a single paragraph using a Paragraph text object.
Using this method, the same three labels noted above would be outputted as follows, without the skipped lines:
Jake Diamond |
Meg Reilly |
All-State Trucking |
To set up your document for this scenario, use the following procedure:
Connecting to a Database
Save the information from the sample data above in a text file, with each item surrounded by quotation marks and separated by commas. Each line should be separated by a carriage return.
In the Data Sources pane of the Toolbox, open the context menu for Database Fields.
Select Database Connection Setup.
In the Add Database Connection Wizard, select Text File.
Click Next.
Click Select File.
In the Specify Text File dialog, navigate to the text file created in Step 1 and click Open.
Click Next.
Select Quote and Comma as the Delimitation Type.
Click Next.
Select Yes when asked "Is the first record of the text field a 'header' that contains the names of the fields?"
Click Finish.
Click OK.
Creating a Text Object
Select from the object toolbar to add a text object. Alternatively, select Text from the Create menu.
From the list of available text types, select Multi-line.
On the template, click on the desired location for the text object.
Configuring the Address
Double-click on the text object to open the Text Properties dialog. Alternatively, select Properties from the object's context menu.
Click to open the New Data Source Wizard.
For Type, select Database Field from the dropdown list and click Next.
For Field, select the desired database field (i.e., CustomerName for the first field in this example).
For Sample Field Data, enter some text resembling the database field. For example, you may enter "Jane Doe" for the field CustomerName.
Click Finish to close the wizard.
Again, click to open the New Data Source Wizard.
This time, select Embedded Data as the data source type.
Click Finish to close the wizard.
In the Embedded Data field of the Data Source property page, highlight the text and press the <Enter> key to insert a carriage return.
Repeat steps 2-5 for each line of the address, with Field and Sample Field Data inputs as follows:
Field "CompanyName"; Sample Field Data "XYZ Company".
Field "StreetAddress"; Sample Field data "555 Williams St.".
Field "City"; Sample Field Data "Seattle".
Field "State"; Sample Field Data "WA".
Field "ZIP"; Sample Field Data "54321".
Copy the embedded data source with the carriage return, and paste it between the database fields for CustomerName, StreetAddress1, StreetAddress2, and City.
Insert an embedded data source that consists of a ", " between City and State.
Insert an embedded data source that consists of a " " between State and ZIP.
Suppressing blank fields
Double-click on the text object to open the Text Properties dialog. Alternatively, select Properties from the object's context menu.
Select the first embedded data source, containing a carriage return.
Select the Transforms tab on the Data Source property page.
Click next to Suppression to open the Suppression dialog.
Select Suppress when previous data source is empty.
Click OK to close the Suppression dialog.
Repeat for each of the embedded data sources that contain a carriage return.
Click Close to close the Text Properties dialog.
Viewing the Data
On the template, you should see the first entry from your database. On the View Navigator, select the Next button and notice that each of the blank lines in your database will no longer appear on your template.
Related Topics