ACC2000: How to Format Controls to Display Bar Code Fonts (271622)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q271622
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SUMMARY

In a Microsoft Access 2000 database, you can display bar codes on forms, reports, and data access pages (embedded fonts only). This display functionality is most often used in reports, but the report formatting depends on the way that the data is entered and stored in the underlying tables.

To correctly display bar codes, the control field must contain not only the numbers and dash (for example, 71043-1643) but also the asterisks on each side of the number (for example, *71043-1643*). To minimize the amount of data stored in the database, the preferred method for correctly displaying bar codes is to format the control properties of the field on the report or form, not in the underlying field in the table.

MORE INFORMATION

Because the raw table data probably does not contain the necessary asterisks, follow these steps to create the table and populate it with data.
  1. Create the following table.
       Table: tblBarCodes
       ----------------------------
       Field Name: ID
       Data Type: AutoNumber
    
       Field Name: Code
       Data Type: Text
    					
  2. Save the table and name it tblBarCodes.
  3. Open the table in Datasheet view.
  4. Type the following records:
       ID    Code 
       ---------------- 
       1     71043-1643 
       2     71043-1655 
       3     71043-1617 
       4     71043-1633 
       5     71043-1634 
       6     71043-1699
    					
The following sets of instructions demonstrate how to format the properties of the control on a report, a form, or a data access page. In order for these instructions to work correctly, the bar code font must be installed on your computer.

Report

  1. Select the tblBarCodes table. On the Insert menu, click AutoReport.
  2. On the View menu, click Design View.
  3. Right-click the Code text box, and then click Properties on the shortcut menu.
  4. Click the Other tab, and then change the name of the control to txtCode.

    NOTE: The bar code may not appear correctly if the name of the control field on the report is the same as the field in the control source (tblBarCodes).
  5. Click the Data tab, and then change the control source from Code to the following:

    ="*" & [Code] & "*"

    NOTE: The name in brackets should be the name of the data control source, not the word "Code".
  6. Click the Format tab, and then change the font to your bar code font.
  7. Preview the report, noting that the bar codes are displayed correctly.

Form

  1. Select the tblBarCodes table. On the Insert menu, click AutoForm.
  2. On the View menu, click Design View.
  3. Right-click the Code text box, and then click Properties on the shortcut menu.
  4. Click the Other tab, and then change the name of the control to txtCode.

    NOTE: The bar code may not appear correctly if the name of the control field on the form is the same as the field in the control source (tblBarCodes).
  5. Click the Data tab, and then change the control source from Code to the following:

    ="*" & [Code] & "*"

    NOTE: The name in brackets should be the name of the data control source, not the word "Code".
  6. Click the Format tab, and then change the font to your bar code font.
  7. Preview the form, noting that the bar codes are displayed correctly.

Data Access Page

  1. Select the tblBarCodes table. On the Insert menu, click Page.
  2. In the dialog box that appears, select AutoPage/Columnar. Make sure that tblBarCodes is selected in the list in the lower right corner.
  3. On the View menu, click Design View.
  4. Right-click the Code text box, and then click Properties on the shortcut menu.
  5. Click the Other tab, and then change the ID of the control to txtCode.

    NOTE: The bar code may not appear correctly if the ID of the control field on the data access page is the same as the field in the control source (tblBarCodes).
  6. Click the Data tab, and then change the control source from Code to the following:

    ="*" & [Code] & "*"

    NOTE: The name in brackets should be the name of the data control source, not the word "Code".
  7. Click the Format tab, and then either select your font name from the Formatting toolbar, or type the exact name of your bar code font in the Font Family box.
  8. Preview the data access page, noting that the bar codes are displayed correctly.

Modification Type:MinorLast Reviewed:7/14/2004
Keywords:kbinfo KB271622