ACC2: "PrtDevMode" Help Example Forces Resave of Report

Last reviewed: April 2, 1997
Article ID: Q132027
The information in this article applies to:
  • Microsoft Access version 2.0

SYMPTOMS

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

If you use either one of the two sample user-defined Access Basic functions in the "Example" section of the "PrtDevMode" topic in the Microsoft Access Help system as it is printed, the function runs correctly, but you are prompted to resave the report after the function finishes running.

CAUSE

The code that saves the report runs before the Painting property of the report is set. Therefore, when the report is closed at the end of the function, Microsoft Access tries to resave the report with the new Painting value.

RESOLUTION

For each of the sample Access Basic functions in the example, move the line that saves the report so that it is after the line that sets the Painting property value. Because the resolution is the same for both sample functions, this section demonstrates the resolution for only the first function in the example.

The first sample Access Basic function in the "Example" section of the "PrtDevMode" topic in the Microsoft Access Help system reads as follows:

   Function SetCopies (MyReport As String, Copies As Integer)
        Dim dm As zwtDevModeStr  ' Structures defined in zwAllGlobals.
   module_ in WZFRMRPT.MDA.
        Dim DevMode As zwtDeviceMode
        DoCmd OpenReport MyReport, A_DESIGN
        Reports(MyReport).Painting = False
        If Not IsNull(Reports(MyReport).PrtDevMode) Then
             dm.rgb = Reports(MyReport).PrtDevMode
             LSet DevMode = dm
             DevMode.dmCopies = Copies
             LSet dm = DevMode
             Reports(MyReport).PrtDevMode = dm.rgb
             DoCmd SetWarnings False
             DoCmd DoMenuItem 7, A_FILE, 2  'This line saves the report.
             DoCmd SetWarnings True
        End If

        Reports(MyReport).Painting = True
        DoCmd Close A_REPORT, MyReport
   End Function

In the sample code above, change the last seven lines of code just below the line that read "Reports(MyReport).PrtDevMode = dm.rgb" to read as follows:

             DoCmd SetWarnings False
             DoCmd SetWarnings True
        End If

        Reports(MyReport).Painting = True
        DoCmd DoMenuItem 7, 0, 2, , A_MENU_VER20  ' Report|File|Save.
        DoCmd Close A_REPORT, MyReport
   End Function
 

	
	


Keywords : kbprint PtrProb
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbdocerr


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.