Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preview or printer for report (A 2002)

    Can a report detect whether it's been opened in Preview or Normal (printer) mode? I want to handle the NoData event differently for the two cases. With preview, I want it to display a messagebox to the user, but with Printer, I just want it to silently Cancel the report without any user intervention.
    Thx.
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

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

    Re: Preview or printer for report (A 2002)

    I don't know how to do this. I found code to detect preview/print in the MS newsgroups. It seems to work in most circumstances, but unfortunately not when there are no data.

    Since the question in general has come up before, I'll still post what I found, it may help others. Put code like the following in the report module.

    <img src=/w3timages/blueline.gif width=33% height=2>

    Private Printing As Integer

    Private Sub ReportHeaderSection_Print(Cancel As Integer, PrintCount As Integer)
    ' Occurs when previewing and when printing
    Printing = Printing + 1
    End Sub

    Private Sub Report_Activate()
    ' Occurs only when previewing
    Printing = -1
    End Sub

    Private Sub Report_Deactivate()
    ' Reset for next time
    Printing = 0
    End Sub

    If the value of Printing is positive (greater than 0), the report is being printed, whether directly, or from preview mode. However, if there are no data, the value doesn't become positive...

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preview or printer for report (A 2002)

    Thanks, Hans. I appreciate the effort.
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

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

    Re: Preview or printer for report (A 2002)

    NoData occurs before either Print or preview, so I don't see any way to do this except perhaps by passing and OpenArgs (newly available in reports in 2002)value to the report to indicate the view being used. Your NoData event could then morph itself depending on the value passed in OpenArgs.
    Charlotte

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preview or printer for report (A 2002)

    Aha! I didn't realize that OpenArgs was now available. It was a glaring omission from earlier versions, and I did not think to look for it. Thanks.
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

Posting Permissions

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