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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with opening a report in "fit to Window mode"

Status
Not open for further replies.

DomFino

IS-IT--Management
Jul 9, 2003
278
US
Hi everyone,
Happy Holidays and Merry Christmas to all.

I am trying to open a report that has a few things going on.

1) The report is executed from a command button on the main menu.

2) A custom tool bar with only two icons (close and print). This seems to work fine.

However, I also want the report to open within the window in preview mode. Then upon printing or closing the report, have it show the main menu in it's original location and size.


I am using the following code on the "On Click" event of the command button:

Code:
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open

    DoCmd.ShowToolbar "GrantTrainkingPrintPreview", acToolbarYes
    DoCmd.OpenReport "rptAllProjects", acViewPreview
    DoCmd.Maximize
    DoCmd.RunCommand acCmdFitToWindow
    
    'The number at the end represents the % zoom 
    DoCmd.RunCommand acCmdZoom75

    If IsLoaded("frmSwitchboard") Then Forms!frmSwitchboard.Visible = False
    
Exit_Report_Open:
    Exit Sub

Err_Report_Open:
    MsgBox Err.Description
    Resume Exit_Report_Open
       
End Sub

I then use this code to close the report:
Code:
Private Sub Report_Close()
On Error GoTo Err_Report_Open

    DoCmd.ShowToolbar "GrantTrainkingPrintPreview", acToolbarNo

    If IsLoaded("frmSwitchboard") Then Forms!frmSwitchboard.Visible = True

    
Exit_Report_Open:
    Exit Sub

Err_Report_Open:
    MsgBox Err.Description
    Resume Exit_Report_Open
       
End Sub

As soon as I click the command button I receive the following error:
The command or action 'fit to window' is not available now. Then the report opens in maximize mode. When I click the close button on the custom tool bar the main menu shows up also in maximized mode.

Any suggestions?
Thanks
Dom
 
All,

I found a solution on this site (faq181-198), which seems to work well.
Thanks
Dom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top