I am running my application in 'Minimized' mode i.e. the Desktop link sets the Run mode to minimized.
All my reports open in 'Preview' mode. When opening a report the following code works fine. The calling Form is minimized, Access window is maximised and the report appears in preview mode.
Public Sub Open_Report(rptReport As Report, strForm As String)
'Label the Report and minimize the calling Form
rptReport.lbl_Report_Header.Caption = strFormReportCaption
DoCmd.SelectObject acForm, strForm
DoCmd.Minimize
'Maximize the MS Access Application
DoCmd.RunCommand acCmdAppMaximize
End Sub
However, when closing the report Preview the following code does not work as I receive the error message as below
Public Sub Close_Report(strForm As String)
'Minimize the MS Access Application
DoCmd.RunCommand acCmdAppMinimize
'Restore the calling form
DoCmd.SelectObject acForm, strForm
DoCmd.Restore
End Sub
'Runtime Error 2046 The Command or Action 'AppMinimize' isn't available now'
All reports 'Open' events Call Open_Report passing 'Me' as the report and the string name of the form to minimize
All reports 'Close' events Call Close_Report passing the string name of the form to restore.
The Form passed is the same for both events.
Any help gratefully received.