Microsoft KB Archive/248945

From BetaArchive Wiki

Article ID: 248945

Article Last Modified on 11/25/2002


  • Microsoft Access 2000 Standard Edition

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).


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


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


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)


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.


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:
    TestID TestField
    1 1
    2 12
    3 123
    4 1234
    5 12345
    6 123456
    7 1234567
    8 12345678
  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

Additional query words: pra wrong not right correct unexpected random

Keywords: kbbug kbfix kbdta KB248945