Results 1 to 11 of 11
  1. #1
    jcc285 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    70

    Minimize Access window on closing report in Preview mode

    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.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    if the report is on screen, you cant see the access window anyway.

  3. #3
    jcc285 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    70
    Quote Originally Posted by ranman256 View Post
    if the report is on screen, you cant see the access window anyway.
    The report in 'Preview' mode is in the Access window.
    Here are some screen shots attached which may clarify the question
    Attached Thumbnails Attached Thumbnails 2046 errorJPG.JPG  

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    It works in other views, do you need it to be in print preview?

  5. #5
    jcc285 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    70
    Yes, because the user then has 'right click' where to send report e.g. printer, excel, pdf file etc.

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Or they could use the ribbon for that, if it is visible. Or you could give them a customized shortcut menu.

    Workarounds!

  7. #7
    jcc285 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    70
    I've now tried several options rather than the Preview Report Close event.
    As all my reports are called from my main switchboard and, that is minimised when the report opens, I have tried it in the Resize event of the form when it is restored, didn't work I'm afraid.
    it seems that once the appcmd window has been maximised for the print preview I cannot minimise it at all from anywhere!

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Could you open the report twice? Once in regular view, hidden or minimized, and second in print preview. When the latter closes, close the other form which will minimize successfully. Or use a bogus form instead.

  9. #9
    jcc285 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    70
    Yes, that worked!! I have a dummy report which has the DoCmd.RunCommand acCmdAppMaximize in it's open event and acCmdMinimize in the close event.
    My main switchboard now opens the dummy report like
    DoCmd.OpenReport "rpt_Dummy",acViewReport,,,acHidden. then I open my real report
    DoCmd.OpenReport "rpt_Real", acViewPreview
    Reverse sequence to get out!! Wonderful!!
    thanks for your, weird, but helpful suggestion.

  10. #10
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Lol. Glad you got it working. Pity we couldn't find the solution, tho.

  11. #11
    jcc285 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    70
    I'll mark the thread as 'solved' although that is a bit of an overstatement.
    Many thanks for your help.
    This is a MS issue clearly. Any ideas if one can report or ask for a fix ?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Minimize form If access Window is restored
    By Lukael in forum Programming
    Replies: 2
    Last Post: 04-02-2016, 10:25 AM
  2. Replies: 1
    Last Post: 12-29-2015, 05:15 AM
  3. Replies: 1
    Last Post: 02-21-2015, 11:35 PM
  4. Automatically Closing Print Preview Window
    By chris.williams in forum Reports
    Replies: 5
    Last Post: 08-07-2012, 05:02 PM
  5. Minimize access window problem
    By McHammer in forum Forms
    Replies: 2
    Last Post: 04-24-2010, 05:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums