Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report calling a Form problems

Status
Not open for further replies.

Gooter

Technical User
Apr 5, 2002
20
US
I have a Report that calls a Form when it is opened (using the OnOpen event procedure). On the Fform are two command buttons, "Preview" and "Save as File". Preview displays the print preview in Access. Save as File will save the report as an .RTF file.

Here is my problem.
I cannot get the Save as File button to work (Preview works fine). This is the error message I get after I click on my button, choose the Output To location and click on OK...

"Run-Time Error '2585' This action can't be carried out while processing a form or event. A macro specified as the OnOpen, OnClose, OnFormat, etc. property setting contains an invalid action for the property."

Do you know why this is happening? I *believe* I setup my buttons correctly because if I go straight to my Form and click on the Save as File button, it works as intended. The problem occurs when the Report calls the Form.

If you need more info, please let me know.

Thanks,
MG
 
Your sequence of calls is backwards. Normally, a form opens a report, not the other way around. A form can open a report for preview, print, or output to a file. For example, if you had three command buttons on your form to run your report in various ways, you might have something like the following code for the buttons:
Code:
Private Sub cmdFile_Click()
  On Error Resume Next
  DoCmd.OutputTo acOutputReport, "Report1"
End Sub

Private Sub cmdPreview_Click()
  On Error Resume Next
  DoCmd.OpenReport "Report1", acViewPreview
End Sub

Private Sub cmdPrint_Click()
  On Error Resume Next
  DoCmd.OpenReport "Report1", acViewNormal
End Sub
You open the form first, and it opens the report in the way you need to have it opened.
 
Ok, that makes sense. Thank you.

Is there any way to make the form close itself out or be minimized to the background once you pick what you want to do (Preview, Print, or Save)? Currently, the form stays up and covers up the report if you pick Preview. It requires that it be manually closed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top