Results 1 to 5 of 5
  1. #1
    bcarter17 is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Jun 2021
    Location
    Richmond MO
    Posts
    46

    Easier, automated way to change specific printers on a group of reports

    Hello,
    I have an application that creates load tickets for loads of rock. The data entry form has 4 tabs to have 4 loads in queue. Based on the business, we either print inside the office on ticket paper (printer 1), inside the office on plain paper (printer 2), or in an outdoor printer inside a box on the scales (printer 3). I created a report for the outside version, with an assigned printer, and a report for each of the 2 inside versions with an assigned printer. This works great.....until.....we have issues with the outside printer due to being out in the weather. This forces us to rotate one of the inside printers outside. Then, to make everything work, I have to go into each report and update the specific printer each needs to go to (12 in total).

    Is there a way instead of assigning a printer in the report, that I could use VB code to find the correct printer from a field on a hidden form? The form has 3 fields (Outside Printer, Inside Printer 1, Inside Printer 2). I could make changes to those 3 fields when we change equipment and quickly update where the reports need to be printed to.

    Any thoughts from the group on using something like this? Would the printer info need to be stored as the assigned network name (example - NPI441173 (HP LaserJet M209dw), or the printer IP address)?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Quick answer to "can I do this" is Yes. I have used VBA to direct output to specific printer. It involves setting a variable to the user's current default printer, changing the default printer, sending job to print, resetting user default printer. Here is simple example
    Code:
    Private Sub btnPrint_Click()
    'print to the color printer
    
    Dim strDefaultPrinter As String
    
    'load the current default printer into the variable strDefaultPrinter
    strDefaultPrinter = Application.Printer.DeviceName
    
    'switch to Konica printer for color printout
    Set Application.Printer = Application.Printers("\\printer server\printer name")
    'try to set printer for color - doesn't work, also tried API coding and that didn't work either
    ''Application.Printer.ColorMode = acPRCMColor
    ''Forms("ConcreteMixTools").Printer.ColorMode = acPRCMColor
    
    Me.Detail.BackColor = vbWhite
    DoCmd.PrintOut
    
    'change back to default printer
    Set Application.Printer = Application.Printers(strDefaultPrinter)
    
    End Sub
    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
    alborg is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2022
    Location
    Virginia, USA
    Posts
    11
    If you are in a situation where you need to reset the current printer for all your reports, s.a. when you are out of the office (as you stated), then this code takes June7's answer a bit further:

    1) place a frame object on a pop up form listing all your possible printer choices
    2) In the form that I use at the office, the end user has to simply click on a radiobutton to get one of these choices-

    On Error GoTo err2
    Select Case Forms![printersel]![Frame7].value
    Case 1
    Xx = "HP LaserJet Pro M12w"
    Case 2
    Xx = "HP LaserJet 1020"
    Case 3
    Xx = "HP LaserJet Pro M12w via LogMeIn"
    Case 4
    Xx = "Microsoft Print to PDF"
    Case 5
    Xx = "NPIA4455E (HP LaserJet M15w) via LogMeIn"
    Case 6
    Xx = "HP LaserJet M14-M17 PCLmS"
    End Select
    Set Application.Printer = Application.Printers(Xx)
    DoCmd.Close acForm, "PrinterSel"
    Exit Sub
    err2:
    MsgBox "This printer object does not exist!", vbExclamation
    Exit Sub


    This will now activate a new printer object which will continue to be active throughout the day, with all of your reports going to that new preferred printer. You can set a "default" printer again in the next time that you open your Access application or pop up the change printer form again to go back to the default printer.

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Really? You'd use an option group with 6 printer options instead of a combo box? When a new option arises, or one is removed, you have to redesign your form instead of simply adding/deleting a record in the table of printer options that could feed a combo box list.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    alborg is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2022
    Location
    Virginia, USA
    Posts
    11
    Yeah, in most situations an updatable combo group would be better, but I had a small office with printers that haven't changed in 20 years, so this pop up form just worked nicely.

    Click image for larger version. 

Name:	MSACCESS_RXqnAE56st.png 
Views:	11 
Size:	156.1 KB 
ID:	51911
    Attached Thumbnails Attached Thumbnails MSACCESS_zrSv0frvzX.jpg  

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

Similar Threads

  1. Printers. How to use specific paper type?
    By TOPSie in forum Access
    Replies: 1
    Last Post: 02-02-2024, 08:47 AM
  2. change specific printer when print reports
    By uoghk in forum Reports
    Replies: 1
    Last Post: 12-22-2022, 10:04 PM
  3. Replies: 9
    Last Post: 07-27-2017, 06:39 AM
  4. Replies: 3
    Last Post: 04-16-2014, 04:29 PM
  5. Replies: 1
    Last Post: 10-18-2011, 07:10 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