ACC2: "PrtDevMode" Help Example Forces Resave of Report

ID: Q132027


The information in this article applies to:


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 
Issue type        : 

Last Reviewed: May 3, 1999