ACC2000: PrintOut Action or Method Fails in MDE and ADE Files (263120)
The information in this article applies to:
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.
- Open the sample database Northwind.mdb.
- Open a new blank form in Design view.
- Add a command button to the form.
- 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
- Save the form, and then close it.
- Open the form in Form view.
- Click the command button. Note that Microsoft Access prints the Alphabetical List of Products report.
- Close the form.
- On the Tools menu, point to Database Utilities, and then click Make MDE File.
- Type Northwind.mde for the file name, select the path where you want Microsoft Access to create the file, and then click Save.
- Close the database.
- Open the Northwind.mde file.
- Open the form that you created earlier.
- 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.
- Open the sample database Northwind.mdb.
- Open a new blank form in Design view.
- Add a command button to the form.
- 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
- Save the form, and then close it.
- Open the form in Form view.
- Click the command button. Note that Microsoft Access prints the Alphabetical List of Products report.
- Close the form.
- On the Tools menu, point to Database Utilities, and then click Make MDE File.
- Type Northwind.mde for the file name, select the path where you want Microsoft Access to create the file, and then click Save.
- Close the database.
- Open the Northwind.mde file.
- Open the form that you created earlier.
- Click the command button.
Note that Microsoft Access prints two copies of the first page of the Alphabetical List of Products report.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 7/14/2004 |
---|
Keywords: | kbbug kberrmsg KB263120 |
---|
|