ACC97: How to Format Controls to Properly Display Barcode Fonts (271488)



The information in this article applies to:

  • Microsoft Access 97

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

SUMMARY

In a Microsoft Access 97 database, you can display barcodes on forms and reports. You would most commonly use this display functionality on reports, but the formatting instructions are the same for forms, and they depend on how the data was entered and stored in the underlying tables.

In order to properly display barcodes, the table field or the report (or form) control must contain not only the numbers and the dash (Example: 71043-1643), but also asterisks on each side of the number (Example: *71043-1643*). To minimize data storage, you should achieve the formatting for the barcodes in the properties of the control on the report (or form), and not in the underlying table field.

MORE INFORMATION

If your table data does not contain the necessary asterisks, follow these steps to format the properties of the control on the report (or form):
  1. Create the following table:
       Table: tblBarCodes
       ---------------------
       Field Name: ID
       Data Type: AutoNumber
    
       Field Name: Code
       Data Type: Text
    					
  2. Save the table as tblBarCodes.
  3. Open the table in Datasheet view.
  4. Type the following records, and then close the table:
       ID    Code 
       ---------------- 
       1     71043-1643 
       2     71043-1655 
       3     71043-1617 
       4     71043-1633 
       5     71043-1634 
       6     71043-1699
    					
  5. In the Database window, click the tblBarCodes table, and then on the Insert menu, click AutoReport.
  6. On the View menu, click Design view.
  7. Right-click the Code text box, and then click Properties.
  8. Click the Other tab, and then change the Name property to txtCode.

    NOTE: This change is needed because the barcode may not be displayed properly if the name of the control on the report (or form) is the same as the name of the field in the control source (the tblBarCodes table).
  9. Click the Data tab, and then change the ControlSource property from Code to:

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

    NOTE: In your database, the name in brackets should be the name of your data control source, not the word "Code."
  10. Click the Format tab, and then change the Font property to the name of your barcode font. Preview the report (or form). Note that the barcodes are displayed properly.


Modification Type:MajorLast Reviewed:9/27/2003
Keywords:kbhowto KB271488