locked
Access 2010: How to determine if a report was actually printed? Used to work in 2003. RRS feed

  • Question

  • Have just converted an Access 2003 ADP database to 2010.

    It all works fine except that this application must detect if a report was actually printed.

    The 2003 version disabled the File--Print function and had a special Print Toolbar which when a report was actually printed (rather than just previewed) executed a function which set a global variable to indicate the report was printed.

    The Print Toolbar is nowhere to be seen in the 2010 version and I suspect the users are using File--Print which is no longer disabled. This means the application is no longer setting the aforementioned global variable and the logic which detects if a report was actually printed no longer works.

    Does anyone have a solution? I must force the user to be only able to print the report via the 'Print' button and when the user does this be able to capture that fact by setting a variable in VBA.

    This is an exceedingly complex application so I'd like to make the minimum changes possible.

    Thursday, October 25, 2012 9:18 PM

Answers

  • AllTheGoodNamesWereTaken wrote:
    > ...
    > I must force the user to be only able
    > to print the report via the 'Print' button and when the user does
    > this be able to capture that fact by setting a variable in VBA. 
     
    I haven't tried it in 2010 but in older versions there's a way to
    determine if a report has been sent to the printer. It works
    because the Activate event of the report only happens if it
    is opened in preview mode. So you can:
     
    1. declare a flag in the declaration section of the report module:
     
    Option Compare Database
    Option Explicit
     
    Dim blnPreview As Boolean
     
    2. "On Activate" of the report
     
    blnPreview = True
     
    3. in an event that only happens once (e.g. Print of the
    report header)
     
    If blnPreview Then
       ' I only take a look
    Else
       ' I print and here's where you set your variable
    End If
     
    blnPreview = Not blnPreview
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     
    • Marked as answer by Dummy yoyo Thursday, November 8, 2012 6:18 AM
    Thursday, October 25, 2012 11:02 PM

All replies

  • AllTheGoodNamesWereTaken wrote:
    > ...
    > I must force the user to be only able
    > to print the report via the 'Print' button and when the user does
    > this be able to capture that fact by setting a variable in VBA. 
     
    I haven't tried it in 2010 but in older versions there's a way to
    determine if a report has been sent to the printer. It works
    because the Activate event of the report only happens if it
    is opened in preview mode. So you can:
     
    1. declare a flag in the declaration section of the report module:
     
    Option Compare Database
    Option Explicit
     
    Dim blnPreview As Boolean
     
    2. "On Activate" of the report
     
    blnPreview = True
     
    3. in an event that only happens once (e.g. Print of the
    report header)
     
    If blnPreview Then
       ' I only take a look
    Else
       ' I print and here's where you set your variable
    End If
     
    blnPreview = Not blnPreview
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     
    • Marked as answer by Dummy yoyo Thursday, November 8, 2012 6:18 AM
    Thursday, October 25, 2012 11:02 PM
  • Very interesting. Thanks. I'll give it a try if I cannot come up with anything better.
    Thursday, October 25, 2012 11:42 PM