ACC2000: PrintOut Action or Method Fails in MDE and ADE Files (263120)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q263120
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SYMPTOMS

When you run the PrintOut action or method to print an object in an MDE or ADE file, you may receive the following error message:
The expression On Click you entered as the event property setting produced the following error:

The command or action 'PrintOut' isn't available now.

CAUSE

This error occurs when you use the PrintOut action in a macro or DoCmd.PrintOut in a module to print a closed object in an MDE or ADE file.

RESOLUTION

Depending on what you are trying to accomplish, there are two possible resolutions.

If you just need to print the entire report, use the OpenReport action instead of the PrintOut action. For example, the following steps demonstrate how to use the OpenReport action to print the entire report.
  1. Open the sample database Northwind.mdb.
  2. Open a new blank form in Design view.
  3. Add a command button to the form.
  4. Set the OnClick property of the command button to the following event procedure:
    Private Sub Command0_Click()
        DoCmd.OpenReport "Alphabetical List of Products", acViewNormal
    End Sub
    					
  5. Save the form, and then close it.
  6. Open the form in Form view.
  7. Click the command button. Note that Microsoft Access prints the Alphabetical List of Products report.
  8. Close the form.
  9. On the Tools menu, point to Database Utilities, and then click Make MDE File.
  10. Type Northwind.mde for the file name, select the path where you want Microsoft Access to create the file, and then click Save.
  11. Close the database.
  12. Open the Northwind.mde file.
  13. Open the form that you created earlier.
  14. Click the command button.
Note that Microsoft Access prints the Alphabetical List of Products report.

However, if you need to specify such features as page range, print quality, and the number of copies to print, you must use the PrintOut action because the OpenReport action does not allow you to specify these features. If you need to take advantage of these features, use the following steps to work around the problem.
  1. Open the sample database Northwind.mdb.
  2. Open a new blank form in Design view.
  3. Add a command button to the form.
  4. Set the OnClick property of the command button to the following event procedure:
    Private Sub Command0_Click()
        Application.Echo False
        DoCmd.OpenReport "Alphabetical List of Products", acViewPreview
        DoCmd.SelectObject acReport, "Alphabetical List of Products", False
        DoCmd.PrintOut acPages, 1, 1, , 2
        DoCmd.Close acReport, "Alphabetical List of Products", acSaveNo
        Application.Echo True
    End Sub
    					
  5. Save the form, and then close it.
  6. Open the form in Form view.
  7. Click the command button. Note that Microsoft Access prints the Alphabetical List of Products report.
  8. Close the form.
  9. On the Tools menu, point to Database Utilities, and then click Make MDE File.
  10. Type Northwind.mde for the file name, select the path where you want Microsoft Access to create the file, and then click Save.
  11. Close the database.
  12. Open the Northwind.mde file.
  13. Open the form that you created earlier.
  14. Click the command button.
Note that Microsoft Access prints two copies of the first page of the Alphabetical List of Products report.

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.
  2. Open a new blank form in Design view.
  3. Add a command button to the form.
  4. Set the OnClick property of the command button to the following event procedure:
    Private Sub Command0_Click()
        DoCmd.SelectObject acReport, "Alphabetical List Of Products", True
        DoCmd.PrintOut
    End Sub
    					
  5. Save the form, and then close it.
  6. Open the form in Form view.
  7. Click the command button. Note that Microsoft Access prints the Alphabetical List of Products report.
  8. Close the form.
  9. On the Tools menu, point to Database Utilities, and then click Make MDE File.
  10. Type Northwind.mde for the file name, select the path where you want Microsoft Access to create the file, and then click Save.
  11. Close the database.
  12. Open the Northwind.mde file.
  13. Open the form that you created earlier.
  14. Click the command button.
Note that you receive the error message mentioned in the "Symptoms" section of this article.

Modification Type:MinorLast Reviewed:7/14/2004
Keywords:kbbug kberrmsg KB263120