Microsoft KB Archive/248945

= ACC2000: The TextWidth Property Returns Incorrect Results =

Article ID: 248945

Article Last Modified on 11/25/2002

-

APPLIES TO


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



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.



Steps to Reproduce Behavior
  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  Save the table, and then open it in Datasheet view. Enter the following data:  In the Database window, click Reports under Objects, and then click New. 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.</li> On the View menu, click Design View. Then on the View menu, click Code.</li>  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 </li> Return to Access and view the report in Print preview.</li> Press CTRL+G to open the Immediate window.</li></ol>

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:

<pre class="fixed_text">  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

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.