Views:

Product: LABELVIEW, CODESOFT

Version: All Versions

 

About Queries

What is a query?

A query is a request for information. By creating a specific request, you are able to extract from the database only the data that you want to include on your label.

Working with queries

A query applies to a single data source. Because of this, you must select the ODBC data source to be queried before constructing the query itself. Changing the data source cancels any previously created query.

Your query defines the tables and fields in the database that you want to include. You can refine the query by defining joins and filters. Once it is defined, you can run the query and display the result before including it in your document. When you are sure the result contains the required data, you can add database variables to your document as text, bar code and—when appropriate—image objects.

Selecting a Sort Order

Sort order

Once you have selected the fields that you want to include in your label, you can sort the records as follows:

  • Ascending sorts text in alphabetical order, numbers in numerical order, and dates and times in chronological order.
  • Descending sorts text, numbers, and dates and times in reverse alphabetical, numerical and chronological order, respectively.

You assign a sort order to a field. For example, assigning Ascending to a Name field sorts the names in alphabetical order.

Sort keys allow you to apply a sort order to several fields, and specify the order in which the sorts take place.

For example, if you apply an ascending sort to a Color field first, and apply a second ascending sort to a Lot Number field, the records are sorted by color and then by lot number, as follows:

If you applied the sort order to the Lot Number field first, this would be your result:

Procedure

To select a sort method:

1. On the Data source menu, click Database and then click Create/Edit query. If the Data Sources pane is open, on the right hand side of the screen, single click on Database option, right click and choose Create/Edit Query. Alternatively, you can press SHIFT + F9. If selecting a query that has already been connected, the Query definition dialog box appears with the tables and fields you have previously selected.

                     

2. Select a Data Source.

3. Select a Table.

4. Select fields to use.

5. Click the Sort button. 

6. Click a sort order (Ascending or Descending).

7. Click the field to be sorted. To apply a sort order to another field, click the sort order and then click the field. Repeat this step to apply a sort order to other fields.

9. To remove a sort order from a field, click the field.

10. Click OK, and save document and query.

                

Displaying Query Results

Query results

To display the results of a query, you must have a document open, and you must have run (merged) a query in that document. The query fields appear under Database in the Data sources window.

Procedure

To display query results:

1. On the Data source menu, click Database and then click View the query resulting data. Alternatively, you can click the View query results button in the Query definition dialog box or on the Merge database browser toolbar. The Query result dialog box appears, displaying a grid that shows the results of your query.

                     

Searching Query Results

Search options

You can search for a specific field, specific data, or both.

Procedure

To search for data in the Query result grid:

1. Click in drop down box, and then click the arrow and select the field you want to search. 

2. In the second text box, type the text or value you want to find.

3. To find records in which any part of the text or value appears, click the button as shown below.

4. To browse the results of the search, use these buttons:
  • Find first occurrence:first occurrence.jpg
  • Find previous occurrence:previous occurrence.jpg
  • Find next occurrence:next occurrence.jpg
  • Find last occurrence:lass occurrence.jpg

Printing Query Results

Print options

The print options allow you to print labels for selected records.

Procedure

To print labels from the Query result dialog box:

1. Click the row (record) that you want to print.

2. In the Quantity column, type the number of labels to be printed for the selected record. If the document contains a counter, this number determines the number of different labels printed (that is, number of counter increments).

3. Repeat steps and In the Quantity column, type the number of labels to be printed for the selected record. If the document contains a counter, this number determines the number of different labels printed (that is, number of counter increments) for each record you want print.
 
4. In the Copies to print box, type the number of label copies. If the document contains a counter, this number determines the number of duplicate labels printed (that is, the counter does not increment).

5. Click the Print button to print the selected labels.

6. Click the Reset button to clear values from the Number to print column.

 

Closing and Saving a Query

About closing

Closing a query removes it from the current document, but does not delete it from its file storage location.

When you close a new or edited query, or when you close a document that contains a new or edited query, you will be prompted to save the query.

Procedure

To close a query:

1. On the Data source menu, click the database name, and then click Close. Alternatively, you can right-click Database in the Data sources tab of the Document Browser, and click Close. If the query is new or if you have made changes to the query, a prompt appears asking if you want to save the query.

             

2. Name the query and save it to the default working folder for queries (.csq files).

         

NOTE: The path to the default working folder is defined in the Default folders tab of the Options dialog box, accessible from the Tools menu. The query is closed and removed from the Data sources tab of the Document Browser.