Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Jan 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preview and Print Report (Access 2003 (2000))

    I have an Invoice Report that I would like to preview first and if everything looks ok print (4) copies. My Problem is that I want (3) copies to show price information and (1) copy to hide it for the packing slip. I am trying to use (1) report instead of (2) to accomplish this. What I have done so far is to add code to the Activate Event with a MsgBox asking to Print or not. What I would like to do, is open the report to preview and then if it looks ok, either hit the print button or a command button that will allow me to print the (4) copies by turning on/off the pricing info. Here is what I have so far:

    If MsgBox("Would You Like To Print This Invoice?", vbYesNo, "Question?") = vbYes Then

    Me.lblInvoice.Visible = False
    Me.lblPackingSlip.Visible = True
    Reports!rptInvoices!sbrInvoiceProducts!ListPrice.V isible = False
    Reports!rptInvoices!sbrInvoiceProducts!txtExtended Price.Visible = False
    Me.txtSubtotal.Visible = False
    Me.txtTaxes.Visible = False
    Me.txtTotal.Visible = False
    Me.Freight.Visible = False

    DoCmd.PrintOut acPrintAll, , , , 1

    Me.lblInvoice.Visible = True
    Me.lblPackingSlip.Visible = False
    Reports!rptInvoices!sbrInvoiceProducts!ListPrice.V isible = True
    Reports!rptInvoices!sbrInvoiceProducts!txtExtended Price.Visible = True
    Me.txtSubtotal.Visible = True
    Me.txtTaxes.Visible = True
    Me.txtTotal.Visible = True
    Me.Freight.Visible = True

    DoCmd.PrintOut acPrintAll, , , , 3

    Else

    Me.lblPackingSlip.Visible = False

    End If

    This is currently working, but I dont feel that it is the most effective way to accomplish what I am trying to do. Currently, you open the report and a MsgBox asks whether to print or not. You choose No and preview it. Then you close the report and open it back up. When the message box appears, you hit Yes. I want to be able to do this without having to close and reopen. Any suggestions would be greatly appreciated.

    Thanks a lot,
    Joey

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

    Re: Preview and Print Report (Access 2003 (2000))

    You cannot place a command button on a report. You could do thw following instead:
    - Create a function PrintReport in a standard module (not in the report module) to print the 1 + 3 copies of the report. You cannot use Me in this code, you must use Reports!rptInvoices instead.
    - Select Tools | Customiza and create a custom toolbar.
    - Place a button on the toolbar.
    - Right-click the button, select Properties and set the On Action property to =PrintReport()
    - Click OK, then close the Customize dialog.
    - Hide (close) the new toolbar.
    - Open your report in design view.
    - Set the Toolbar property (in the Other tab of the Properties window) to the name of your custom toolbar.

  3. #3
    New Lounger
    Join Date
    Jan 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preview and Print Report (Access 2003 (2000))

    Thanks for your reply. That will work fine. However, when I try to do this I keep getting a run-time error stating that the expression has an invalid reference. Do you have any suggestions? Here is my code:

    Function PrintInvoice()

    Reports!rptInvoices!lblInvoice.Visible = False
    Reports!rptInvoices!lblPackingSlip.Visible = True
    Reports!rptInvoices!sbrInvoiceProducts!ListPrice.V isible = False '<---- CODE BREAKS HERE BECAUSE THE EXPRESSION IS INVALID
    Reports!rptInvoices!sbrInvoiceProducts!txtExtended Price.Visible = False
    Reports!rptInvoices.txtSubtotal.Visible = False
    Reports!rptInvoices.txtTaxes.Visible = False
    Reports!rptInvoices.txtTotal.Visible = False
    Reports!rptInvoices.Freight.Visible = False

    DoCmd.PrintOut acPrintAll, , , , 1

    Reports!rptInvoices.lblInvoice.Visible = True
    Reports!rptInvoices.lblPackingSlip.Visible = False
    Reports!rptInvoices!sbrInvoiceProducts!ListPrice.V isible = True
    Reports!rptInvoices!sbrInvoiceProducts!txtExtended Price.Visible = True
    Reports!rptInvoices.txtSubtotal.Visible = True
    Reports!rptInvoices.txtTaxes.Visible = True
    Reports!rptInvoices.txtTotal.Visible = True
    Reports!rptInvoices.Freight.Visible = True

    DoCmd.PrintOut acPrintAll, , , , 3

    End Function

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

    Re: Preview and Print Report (Access 2003 (2000))

    The line that causes the error is the same as in your original code. You stated it was working correctly then, so I don't understand why it wouldn't work now.

  5. #5
    New Lounger
    Join Date
    Jan 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preview and Print Report (Access 2003 (2000))

    I agree. That is why I am stumped.

    Thanks,
    Joey

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

    Re: Preview and Print Report (Access 2003 (2000))

    Ah! The problem is that you cannot refer to controls on the subreport once the report has been opened. So your original approach is actually the best one. You'd have to close and reopen the report anyway. Sorry for the red herring.

Posting Permissions

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