Views:

Product: LABELVIEW, CODESOFT
Version: All Versions

The Table Lookup feature allows LABELVIEW and CODESOFT to retrieve information from an external database that is different from the database currently merged with the label. A Table Lookup searches the external data source using a matching value (Key Field and Key Value) and returns the information from a selected result field.

In this example, a Serial Number entered at print time is used to look up and return a corresponding Color value from an external database.


Before You Begin

Before creating a Table Lookup variable, ensure the following requirements are met:

  • An external database is available.
  • The appropriate ODBC driver is installed if required.
  • A connection to the external data source has been created.
  • A When Printed variable exists that will be used as the lookup value.

NOTE: Table Lookup variables are grouped beneath the table name in the Data Sources window. If multiple variables use the same external table, additional Table Lookup variables can be created by right-clicking the existing table name.


Create a Table Lookup Variable

1. Create a When Printed variable in your label. This variable supplies the value that will be searched in the external database when the label is printed.

The When Printed variable should correspond to the field used for matching records in the external database. In this example, the When Printed variable is Serial Number.

NOTE: Instructions for creating a When Printed variable are available here.

2. In the Data Sources window, right-click Table Lookup, then select Add.

3. In the Table Lookup window, enter a descriptive name for the new Table Lookup variable. Using the name of the expected result field makes future maintenance easier.

For this example, name the Table Lookup variable Color because it will return the Color value associated with the Serial Number entered at print time.

4. On the Table Lookup tab, select the external data source that contains the information you want to retrieve. If necessary, create a new data source before continuing.

NOTE: Instructions for connecting to an external data source are available here.

5. From the Select Table list, choose the table that contains the data you want the Table Lookup to search.

7. Create the Key field.
  • Click the Append row button to create a new Key field.

8. Select the Key field.
  • Under the Key field column, select the reference field from the external data source.
  • This is the field that the lookup will search against.

This is the value that the Key value will be compared to. In this example, the database column is Serial.

9. Select the Key value.
  • Under the Key value (data source) column, select the variable whose value will be compared against the value in the external database.

Think of this as selecting the When Printed variable that will be used to perform the lookup. In this example, the variable is Serial Number.

Note: Enabling Use format value with the key-value (under the Data formatting tab) allows the lookup to use the formatted value, including any prefixes or suffixes.

10. Test the lookup.
  • Click Test in the lower-right corner of the Table Lookup window.
  • This verifies that the lookup returns the expected value.

11. Review the test results.
  • A dialog box displays the lookup result.
  • Close the dialog after reviewing the returned value.

12. Save the Table Lookup.
  • If the test results are incorrect, review the configuration and make any necessary changes.
  • Repeat the test until the expected value is returned.
  • When the Table Lookup is configured correctly, click OK.

13. Verify the Table Lookup variable.
  • After saving, the table name appears under Table lookup in the Data Sources window.

14. Place the Table Lookup on the label.
  • In the Data Sources window, select the Table Lookup variable (for example, Sheet1$: Color).
  • Right-click the variable and select Place.
  • Click the desired location on the label.
  • Select how the variable should be displayed:
    • Text
    • Barcode
    • Image

15. Print the label.
  • The Table Lookup variable now displays the value returned from the external data source.
  • Each time a different Serial Number is entered into the When Printed variable, the Table Lookup returns the corresponding value (such as Color) from the external table.