View Full Version : AppMinimize & AppMaximize Problems


Deez
01-18-2007, 06:37 AM
I ma trying to use these commands to view reports in a database in which the Access window has been minimized. To do this you need to maximize the access window and then open the report. When the report is closed you must then minimize access again. I recieved this info from this thread:
http://www.access-programmers.co.uk/forums/showthread.php?t=20065&highlight=appminimize
(http://www.access-programmers.co.uk/forums/showthread.php?t=20065&highlight=appminimize)
The problem lies in that when I put the AppMaximize and AppMaximize commands in the on open and on close events I get the error saying they are not available now. I believe it has to do with the fact that the original form is still open in some small way. I put the close line above the AppMaximize in the macro as well as just after the call to open the report in the code from the form neither seems to work. The only solution I have found is to go to a macro to open the report and then on open of the report run the maximize command. Then having the close command in the on open event of the report works just fine.

However this creates and excessive amount of macros, so is there a better way around this?

boblarson
01-18-2007, 06:55 AM
In the event on the form, that opens the report, you must put the code to maximize the app, close the form, open the report in that order.

So, for example, if I have a button that opens a report, the code order would be:
In the Form Load event when the Database opens:

Private Sub Form_Load()
DoCmd.RunCommand acCmdAppMinimize
End Sub



In the click event of the button to open the report:

Private Sub cmdOpenReport_Click()
DoCmd.Close acForm, Me.Name, acSaveNo
DoCmd.RunCommand acCmdAppMaximize
DoCmd.OpenReport "ReportSample", acViewPreview
End Sub


In the report's Open event:

Private Sub Report_Open(Cancel As Integer)
DoCmd.Maximize
End Sub



In the report's Close event:

Private Sub Report_Close()
DoCmd.OpenForm "Form1", acNormal
DoCmd.RunCommand acCmdAppMinimize
End Sub



If followed like that, it should work for you just fine (I just retested it to double-check as I haven't used it for quite some time since it is a pain to have to make sure it all happens in that specific order).

Deez
08-10-2007, 11:32 AM
I know this is old, but I came back to it in attempt to get right clicking to work in reports so there was the ability to print again. Anyways I still get the same error and I believe it is because I need to close all forms, but I need info in one of the forms to filter the report so this will not work for me.

boblarson
08-10-2007, 11:50 AM
but I need info in one of the forms to filter the report so this will not work for me.
Actually, this is not quite accurate. You CAN set public variables to the information you need from the form before closing it to display the report.