Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: The TextWidth Property Returns Incorrect Results


View products that this article applies to.

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

↑ Back to the top


Symptoms

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

↑ Back to the top


Cause

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

↑ Back to the top


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)

↑ Back to the top


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.

↑ Back to the top


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:
    Collapse this tableExpand this table
    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

↑ Back to the top


Keywords: KB248945, kbdta, kbfix, kbbug

↑ Back to the top

Article Info
Article ID : 248945
Revision : 1
Created on : 11/25/2002
Published on : 11/25/2002
Exists online : False
Views : 295