Results 1 to 5 of 5
  1. #1
    lzook88 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    75

    Printing Access Report

    The VBA code to print out an access report is printing the report and the form where the button to print the report is. Below is the code:

    Code:
    Private Sub Command2_Click()
    DoCmd.OpenReport "Needed Stock", acViewNormal, , "[PLocation] =" & Chr(34) & Me.Combo0.Column(1) & Chr(34), acDialog
    DoCmd.Close acForm, "StockNeeds", acSaveNo
    DoCmd.PrintOut
    DoCmd.Close acReport, "Needed Stock", acSaveNo
    End Sub
    I have it set up to:



    1.) Open the form and filter results
    2.) Close Form where button is
    3.) Print out report
    4.) Close the report

    But I'm getting the report and the form printing out. any suggestions?

    Thanks Again
    Zook

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Why close the form?

    Specify the report name in the PrintOut object argument.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    lzook88 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    75
    The form is a popup from the main navigation asking which unit you want print the report for.

    I got it to work. Not sure whats going on with it. But i removed the print out code and left the rest and it opens, prints, closes now.

    But I'm curious as to why its printing out with out any coding. Any ideas?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    It is coded to print. That is what acViewNormal does.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Ooops, I should have noticed the acViewNormal. I had assumed you were opening the report to screen view. acViewNormal means direct to default printer. So the report printed then the PrintOut command executed to print the last object that had focus - the form, even though it was closed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-04-2014, 10:12 AM
  2. Replies: 6
    Last Post: 08-21-2014, 11:02 AM
  3. Replies: 1
    Last Post: 03-08-2013, 03:05 PM
  4. Replies: 4
    Last Post: 01-08-2013, 04:14 AM
  5. Printing report crashes access
    By romebrown in forum Reports
    Replies: 2
    Last Post: 11-23-2011, 10:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums