Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Oct 2002
    Location
    New Salem, North Dakota, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    print to a printer automatically using code (2000)

    Is there anyway to automatically send a report to a printer automatically? Can you give me a place to start with the code to do this?

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

    Re: print to a printer automatically using code (2000)

    The code to print a report named MyReport is

    DoCmd.OpenReport "MyReport"

    You could call this code for instance in the On Click event procedure of a command button on a form. If you want to print specific pages of a report, you must open the report in preview mode first and then use DoCmd.Printout followed by information about the pages you want to print. Post back if you need more help.

  3. #3
    Star Lounger
    Join Date
    Oct 2002
    Location
    New Salem, North Dakota, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: print to a printer automatically using code (2000)

    This will print to the printer that is set as the default printer?

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

    Re: print to a printer automatically using code (2000)

    It will print to the printer that is set in the Page tab of File | Page Setup... (with the report open in design or preview mode).

  5. #5
    Lounger
    Join Date
    May 2003
    Location
    tunbridge wells, Kent, England
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: print to a printer automatically using code (2000)

    Hi

    In a similar vein to the original post, how can I automatically print a report at, say, the beginning of each month (excluding the weekends)? If the beginning of the month is at the weekend, could it be printed, or prompt me to print, on the next opening of Access after the 1st of the month?

    Any help would be appreciated (for a non-code writer but I'm getting good at cut'n'paste!)

    Regards
    Suek

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: print to a printer automatically using code (2000)

    One way to do this is to setup a database with the form, query and any linked tables (I presume they are linked) required for the report to run.

    You could put a OnTimer event on the form to wake up every 10 minutes (say) and test if it is required to run as against when it was last run and kick off the report if required.
    Test for a Saturday or Sunday so you don't kick off the report on the weekend.
    After the report has run you could set the date/time when the report was last run so that it does not continue to be run.

    This database would be running all the time.

  7. #7
    Lounger
    Join Date
    May 2003
    Location
    tunbridge wells, Kent, England
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: print to a printer automatically using code (2000)

    Hi Pat

    Many thanks for your reply. I'll give it a try!

    Best regards,
    Sue

Posting Permissions

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