Microsoft KB Archive/178886

= ACC97: "Division by Zero" Error Using Publish To The Web Wizard =

Article ID: 178886

Article Last Modified on 1/22/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q178886



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
After you set the ScaleMode property in a report to 5 or to 7 and try to publish the report as HTML by using the "Publish to the Web Wizard," the wizard may fail, and you may receive the following error message:

Division by Zero.



CAUSE
This behavior occurs if the following conditions are true:


 * The ScaleMode property of any of the following sections is set to 5 or to 7:


 * Report Header or Footer
 * Page Header or Footer
 * Group Header or Footer
 * The following types of controls are in the sections:


 * Labels
 * Text boxes
 * Combo boxes
 * List boxes
 * Option buttons
 * Option groups
 * Check boxes
 * Bound object Frames
 * Subreports



RESOLUTION
The ScaleMode property, in conjunction with the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties are generally used to create custom coordinate systems for purposes of drawing or changing the size of objects on a report or form.

If it is necessary to use inches or centimeters as a scale, you can do so by setting the ScaleMode property to 1 (Twips), and then using the following conversions to arrive at an equivalent setting in inches or centimeters:


 * 1440 Twips equals one logical inch
 * 567 Twips equals one logical centimeter

How to Use the ScaleMode Property
The following steps illustrate how you can draw two circles that appear as though they are the same size even though a different ScaleMode property is used with each one:

 In Microsoft Access 97, open a new blank database. In the Database window, click the Reports tab. Click New to create a report in Design view. Do not select a table or query to base the report on. Click OK. Using the right mouse button (right-click), click inside the Details section of the report and click Build Event on the shortcut menu. In the Choose Builder dialog box, click Code Builder, and then click OK.  Type or paste the following event procedure in the Module window:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

' Set the ScaleMode property of the Details section to 5 (Inches)

Me.ScaleMode = 5

' Draw a circle in the Details section with a radius of .25 ' Inches.

Circle (ScaleWidth / 2, ScaleHeight / 2), 0.25

End Sub </li> Close the Module window.</li>  While in Design view of the report, right-click in the Page Footer section. On the shortcut menu, click Build event and type or paste the following procedure:

Private Sub PageFooter_Format(Cancel As Integer, FormatCount As _      Integer)

' Set the ScaleMode property of Page Footer section of the report ' to 1 (Twips)

Me.ScaleMode = 1

' Draw a circle in the Details section of the report with a         ' radius 1 of .25 Inches by multiplying .25 by 1440 which will ' return the equivalent of .25 Inches

Circle (ScaleWidth / 2, ScaleHeight / 2), (0.25 * 1440)

End Sub </li> Close the Module window and save the report as MyReport.</li> Open the newly created report by selecting the Reports tab, and then double-clicking MyReport.

While viewing the report, notice that the circumference of the two circles are the same even though a different ScaleMode setting was used to render each one.</li></ol>

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> Repeat steps 1-5 in the "How to Use the ScaleMode Property" section.</li>  Type or paste the following event procedure in the Module window:

Private Sub Detail_Format(Cancel As Integer, FormatCount As _      Integer)

' Set the ScaleMode property of the Details section to 5 (Inches)

Me.ScaleMode = 5

End Sub </li> Save changes and close the Module window.</li> Add an unbound text box to the Details section of the report.</li> Save the Report as MyTestReport and close it.</li> On the File menu, click Save As HTML.</li> When the "Publish to the Web Wizard" screen appears, click Next.</li> Click to select the MyTestReport check box.</li> Click the Finish button.

Note that you receive the error message mentioned in the "Symptoms section."</li></ol>

<div class="references_section">