Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Northern, NJ, New Jersey, USA
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Report Open/Close VB (2000)

    I have one report that OnOpen has VB to DoCmd.Maximize and OnClose has VB to DoCmd.Restore

    Is there a place in the VB of the Access Db that I can Maximize and then restore ALL REPORTS on open and close? or do I need an event procedure for each reports in two place?
    There is always a way.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Report Open/Close VB (2000)

    If you like, you can do the following:
    <UL><LI>In a standard module (one you create by clicking New in the Modules tab of the database window), enter two functions:

    Function DoMaximize()
    DoCmd.Maximize
    End Function

    Function DoRestore()
    DoCmd.Restore
    End Function

    <LI>Open a report in design view.
    <LI>Activate the Events tab of the Properties window.
    <LI>In the On Open event, type =DoMaximize()
    If you wish the report to maximize whenever you activate it after switching to another window, enter this in the On Activate event.
    <LI>In the On Close event, type =DoRestore()
    If you wish to restore the window to normal size whenever you deactivate it by switching to another window, also enter this in the OnDeactivate event.[/list]You'll have to do this for each report (or use a template). Downside is that the database is less self-documenting, for you can't see in the report module (if the report has one) that you have an OnOpen and OnClose event handler.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Northern, NJ, New Jersey, USA
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report Open/Close VB (2000)

    Awesome

    Thanks again!
    There is always a way.

  4. #4
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Northern, NJ, New Jersey, USA
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report Open/Close VB (2000)

    Is there a command to alter the view to "FIT" when the report opens maximized? and where would you put it?
    There is always a way.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Report Open/Close VB (2000)

    There is such a command, but unfortunately, you can't call it in the On Open or On Activate event of the report itself - those events occur before there are data to display, so you can't put it in the functions I provided in my previous reply.

    You can call it after you have opened a report using DoCmd.OpenReport, for example in the On Click routine for a command button on a form:

    Private Sub cmdReport_Click()
    DoCmd.OpenReport "rptMyReport", acViewPreview
    RunCommand acCmdFitToWindow
    End Sub

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Report Open/Close VB (2000)

    What do you mean "to fit"? If you're talking about fit to window, use this:

    DoCmd.RunCommand acCmdFitToWindow

    You put it in the report's code module right after the DoCmd.Maximize.
    Charlotte

  7. #7
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Northern, NJ, New Jersey, USA
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report Open/Close VB (2000)

    Hanz is right in that you can't put it on the OnOpen of the report. I tried and I get an error that the acCmdFitToWindow is not available.

    I have some reports that are activated by a command button and I will try it there.

    Thanks!!!
    There is always a way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •