Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2008
    Posts
    150

    Unanswered: Printing a Report directly from a Form

    Hello,

    I have an input form that I would like to print from using a report. I would like to click on a button on my input form and have it automatically print the new record that I entered. I would like to bypass print preview and print directly to the printer.

    Here is the code I am using. The problem with this code is that the report opens in the print preview mode and does not display the record that I entered.

    Private Sub Print_New_WO_Report_Button_Click()
    On Error GoTo Err_Print_New_WO_Report_Button_Click

    DoCmd.OpenReport " WO_Problem_Report", acViewPreview, , _
    "[WO_Number]=Forms!input_wo_form"

    Exit_Print_New_WO_Report_Button_Click:
    Exit Sub

    Err_Print_New_WO_Report_Button_Click:
    MsgBox Err.Description
    Resume Exit_Print_New_WO_Report_Button_Click

    End Sub

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,420
    Provided Answers: 7
    you need to change the "acViewPreview"

    to can't remeber sorry ( not at my desk)

    click on Openreport the press F1 this will tell you all you need to now
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Private Sub Print_New_WO_Report_Button_Click()
    On Error GoTo Err_Print_New_WO_Report_Button_Click

    DoCmd.OpenReport " WO_Problem_Report", acViewPreview, , _
    "[WO_Number]=Forms!input_wo_form"

    Exit_Print_New_WO_Report_Button_Click:
    Exit Sub

    Err_Print_New_WO_Report_Button_Click:
    MsgBox Err.Description
    Resume Exit_Print_New_WO_Report_Button_Click

    End Sub
    Try to write your own VBA rather than using the Wizards. If you did, your code would probably look like this:

    DoCmd.OpenReport " WO_Problem_Report", , , "[WO_Number]=Forms!input_wo_form"

    Seems a lot simpler to me
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Sep 2008
    Posts
    150
    Oh thank you StarTrekker! Exactly what I needed.

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    ^^ You're welcome
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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