You cannot open a report in Print Preview view or to print in Access 2002

Article translations Article translations
Article ID: 320713 - View products that this article applies to.
This article was previously published under Q320713
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).

Expand all | Collapse all

On This Page

SYMPTOMS

When Microsoft Access attempts open a report, it will automatically switch to Design view if an existing Print Preview view of the same report is not first closed. The report will switch views both in MDB and MDE files.

RESOLUTION

Currently, there are only two known ways to work around this problem:
  • Use code to check the status of the report.
  • Use Access security to remove the Read Design permission.

Method One: Use Code to Check the Status of the Report

You can use the AllReports collection to check the status of the report. If the report is currently open in Print Preview view, you can issue a command to close the report and then issue a command to open it for printing. To see an example of how to do this, follow these steps:
  1. Create a module, and then type the following line in the Declarations section if it is not already there:
    Option Explicit
    						
  2. Type the following procedure:
    Public Sub PrintReport(strReportName As String)
        Dim accobj As AccessObject
    
        'This function closes the open report and then re-opens it.
    
        Set accobj = application.CurrentProject.AllReports.Item(strReportName)
    
        If accobj.IsLoaded Then
           If accobj.CurrentView = acCurViewPreview Then
              DoCmd.Close acReport, strReportName
              DoCmd.OpenReport strReportName, acViewNormal
           End If
        Else
           DoCmd.OpenReport strReportName, acViewNormal
        End If
    
    End Sub
    						
  3. To test this procedure:
    1. Switch back to the Database window and then open your report in Print Preview. Switch back to the Visual Basic Editor.
    2. In the Immediate window, type the following, and then press ENTER:
    PrintReport "ReportNameHere"
    						
    Notice that if your report is closed, you can reopen it and Access will not switch to Design view.

Method Two: Use Access Security to Remove the Read Design Permission

Users who cannot access Design view will not see this problem. Therefore, you can prevent this problem by using Microsoft Access security to remove a user's Read Design permission. This will restrict a user's access to Design view.

For additional information about how to secure a database in Microsoft Access, click the following article numbers to view the articles in the Microsoft Knowledge Base:
289885 Description of how to help protect a Microsoft Access database
305542 ACC2002: Understanding the Role of Workgroup Information Files in Access Security

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Open the sample database Northwind.mdb, and then create a new form.
  2. Add a command button to the form, and then set the OnClick property to the following event procedure:
    DoCmd.OpenReport "Catalog", acViewNormal
    						
  3. Close and save the form as TestForm.
  4. In the Database window, double-click the Catalog report. Do not close it.
  5. In the Database window, open your TestForm form, and then click your command button.
Notice that the Catalog report switches to Design view.

REFERENCES

For more information about the AllReports collection, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type AllReports in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about Access security, click Microsoft Access Help on the Help menu, type Secure an Access database and its objects with user-level security in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Properties

Article ID: 320713 - Last Review: August 18, 2004 - Revision: 3.2
APPLIES TO
  • Microsoft Access 2002 Standard Edition
Keywords: 
kbtshoot kbprint kbdta kbprb kbpending kbprintpreview KB320713

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com