hpoyta
Apr 11 2005, 08:46 AM
First off the error that I am getting is: "The command or action 'OpenReport' isn't available now"
I have a form that allows a report to be opened in preview mode or opened in print mode (depending on which button is clicked on the form). If the report is opened in preview mode, the error does not occur, but whenever the report is opened in print mode, it does. Likewise, I try to print the report (from the file menu) once it has been opened in preview mode the error occurs. Now even though I am getting this error, the report still prints in both cases. Can anyone tell me why I am getting this error and how I can get rid of it?
Thank you
Hal
Millennas
Apr 11 2005, 08:56 AM
When a report is printed from preview mode, it is in fact closed then opened again. If your report closes the calling form, then this can cause errors as the form is not there when expected. In a similar vein, it could be a type of recursion.
hpoyta
Apr 12 2005, 09:05 AM
How can I get rid of the problem, though? I do want to close the calling form after I open the report and then have the OnClose action of the Report reopen the form. I tried leaving the form open and minimizing it and printing the report that way, but I still got the error. What do you mean by a type of recursion? Maybe I should of mentioned this before - I didn't think it was important, but since I don't know how recursion plays into this, maybe it is, but the report has a subreport on it, which in turn has a subreport on it.
There is no record source attached to the main report, but both subreports have different recordsources - The main report just provides the table headers and title in the page header section and the date and page number in the page footer section. The entire details section is a subform that is the data associated with the headers. One of the columns is from a different table as there are many items of it associated with one record. for example say a listing of classes at a school:
The main form is the row headers
The subform has all information kept about the classes (all from one table)
The subform on the subform has all students in the class (from another table)
For some reason the columns won't line up - they are suppose to, though.
Main form:
Class Listings
Students | Course #| Building | Time | Days | Credits | Teacher
-------------------------------------------------------------------------------------------------------------------
SubSubForm: Sub Form:
Jon Henderson | 12345 | XYZ | 1-2 | MWF | 3 | Jim Jones
Jason Preston
Emily Tanzey
Daniel Rogers | 54321 | ZYX | 2-3 | TR | 2 | Carol Smith
Mickey Glago
This is the only code - it's from the main report:
Private Sub Report_Close()
On Error GoTo Err_Report_Close:
DoCmd.OpenForm "Main Page"
End_Report_Close:
Exit Sub
Err_Report_Close:
MsgBox Err.Description
Resume End_Report_Close
End Sub
Any help would most appreciated
Thank you
Hal
hpoyta
Apr 12 2005, 09:13 AM
I got it - I had code in the subreport that to reset the OrderBy to the default when it closed - I took that out and put it in the main page. I see that must be what you meant by the recursion - The reportclose - would call the report open - which would call the report close, and etc... - Thank you for your help Millennas. You have been most helpful.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.