ACC2000: The TextWidth Property Returns Incorrect Results (248945)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q248945
Advanced: Requires expert coding, interoperability, and multiuser skills.

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

SYMPTOMS

When you run a report that contains code which dynamically calculates width, you notice that the calculations are incorrect.

CAUSE

The TextWidth property returns incorrect results. Consequently, any changes that you make to the report based on this property are incorrect.

RESOLUTION

To resolve this problem, obtain Microsoft Office 2000 Service Release 1/1a (SR-1/SR-1a).

To obtain SR-1/SR-1a, click the article number below to view the article in the Microsoft Knowledge Base:

245025 OFF2000: How to Obtain and Install Microsoft Office 2000 Service Release 1/1a (SR-1/SR-1a)

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was corrected in Microsoft Office 2000 SR-1/SR-1a.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In a new Access database, create the following new table:
       Table: TestTable
       ----------------------------
       Field Name: TestID
       Data Type: AutoNumber
       Indexed: Yes (No Duplicates)
    
       Field Name: TestField
       Data Type: Text
  2. Save the table, and then open it in Datasheet view. Enter the following data:
    TestIDTestField
    11
    212
    3123
    41234
    512345
    6123456
    71234567
    812345678
  3. In the Database window, click Reports under Objects, and then click New.
  4. In the New Report box, click AutoReport: Tabular, click TestTable in the Choose the table or query where the object's data comes from box, and then click OK. The new report appears.
  5. On the View menu, click Design View. Then on the View menu, click Code.
  6. Type the following code:
    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
       Debug.Print "Value:'" & Me.TestField & _
         "'"; vbTab & "TextWidth:" _
         & Me.TextWidth(Me.TestField); vbTab _
         & "TextHeight:" & Me.TextHeight(TestField)
    End Sub
  7. Return to Access and view the report in Print preview.
  8. Press CTRL+G to open the Immediate window.
In the Immediate window, you see something similar to the following output. (The actual numbers may vary from system to system because of different screen resolutions.) You would expect the TextWidth property values to increment smoothly as the width of the field increases. Instead the values appear to increase and decrease randomly:
   Value:'1'    TextWidth:629    TextHeight:158
   Value:'12'    TextWidth:254    TextHeight:158
   Value:'123'    TextWidth:302    TextHeight:158
   Value:'1234'    TextWidth:629    TextHeight:158
   Value:'12345'    TextWidth:610    TextHeight:158
   Value:'123456'    TextWidth:1003    TextHeight:158
   Value:'1234567'    TextWidth:984    TextHeight:158
   Value:'12345678'    TextWidth:1310    TextHeight:158

Modification Type:MajorLast Reviewed:11/25/2002
Keywords:kbbug kbdta KB248945