Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    code for print? (Access 2000)

    I am drawing a blank on how to print a query using VB code for an event?

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: code for print? (Access 2000)

    I'm afraid we need more information to be able to help you. Are you wanting to create a report, or write a query to a file, or what?
    Wendell

  3. #3
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code for print? (Access 2000)

    I just want to write code that prints a query, like DoCmd.Print "Query1"

    something like that??

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: code for print? (Access 2000)

    <P ID="edit" class=small>(Edited by WendellB on 31-Jul-03 13:51. Added code to open query in Print Preview)</P>Why not just run the query and then print the result? To do that in VBA is rather complicated, but it can be done with a good deal of code, and you have constant challenges in terms of knowing who has what printer and where the output will go. Letting the user handle those issues is usually the preferred alternative.

    I should add that you can open a query in Print Preview mode, which is only one click away from printing it immediately. The code to do that is <font color=blue><font face="Georgia">
    DoCmd.OpenQuery "qryMyQueryName", acViewPreview, acReadOnly</font face=georgia></font color=blue>
    Wendell

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

    Re: code for print? (Access 2000)

    DoCmd.Print doesn't exist, but DoCmd.PrintOut does. It prints the active object to the standard printer, you can't specify an object to print or select a printer.

    DoCmd.OpenQuery "queryname"
    DoCmd.PrintOut

Posting Permissions

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