Results 1 to 7 of 7
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Print form to choice of printers

    Using A2007. I am trying to print only page 1 of a form using code that allows the user to select one of several printers.
    The code I tried is a variation of what I used in the other system computers that use the default printer:

    Me.FilterOn = True
    Me.Filter = "idquote=" & Me.idQuote & ""
    DoCmd.RunCommand acCmdSelectRecord '

    DoCmd.PrintOut acPages, 1, 1 '
    I replaced the PrintOut command with SendKeys ("^p") '



    Me.Filter = "idob=" & Me.IDob & ""

    With SendKeys command, the user gets to select the printer but the printout doesn’t limit itself to page 1, so extra non-needed pages are printed.. Is there some way to limit the printout to the first page only and still be able to choose a non-default printer?

    Any help much appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Can have code present the user with a list of printers then set default printer. Be sure to first set a variable to the current default so can set it back.
    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
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Quote Originally Posted by June7 View Post
    Can have code present the user with a list of printers then set default printer. Be sure to first set a variable to the current default so can set it back.
    Thanks for quick reply, but some misunderstanding here. The SendKeys command that I showed in my code presents the user with the list of printers. The problem is that I need to restrict the printing to only the first page of the form.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Apparently SendKeys ("^P") just opens printer dialog where user would have to select print range as well as printer destination. Everything I read about SendKeys advises against their use, although I have out of desperation. If you want to control the print range, then cannot use printer dialog which transfers control to the user.
    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.

  5. #5
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Apparently the phrase I should have used in Google searches was "Access vba set default printer". The one I tested and am using was recommended on a couple of sites. It was defined for A2000 but works fine in A2007. It is available at
    http://bytes.com/topic/access/answer...ecific-reports
    The simplest solution didn't work, but the more complex one works great.

  6. #6
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    If don't need a choice of printers but just want to print to a certain non default printer, this works:
    Private Sub Command0_Click()
    SaveDefaultPrinter
    DefaultPrinter = "Canon MG3500 SERIES printer"
    DoCmd.OpenForm "FORM1"
    DoCmd.PrintOut , 1, 1
    RestoreDefaultPrinter
    End Sub

  7. #7
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Correction:Simple Code above didn't work on some computers in system. More complex code worked consistently.

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

Similar Threads

  1. Replies: 5
    Last Post: 08-06-2015, 03:26 PM
  2. Replies: 5
    Last Post: 07-29-2014, 01:05 PM
  3. Replies: 5
    Last Post: 06-25-2014, 09:19 AM
  4. Replies: 5
    Last Post: 04-11-2012, 06:52 PM
  5. How do I put a multi-choice option on my form?
    By Dollydriver in forum Forms
    Replies: 13
    Last Post: 02-09-2011, 05:40 PM

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