Results 1 to 7 of 7
  1. #1
    TOPSie is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    101

    Reports("MyRep").Printer.DeviceName

    As I am not sure I understand this, then the following may be vague or confused - but I need to know how to handle this, so pointers and answers would be good - Thank you in advance.



    I am supporting a distribution company which is controlled by an Access (2016) database. Part of the operation is to label boxes for delivery. They have 6 or seven dedicated label printers each loaded with pre-printed labels. The Access db has an interface to manage printing. The operator chooses the label type and adds a few specific items (e.g. Best Before Date) which overprint the labels.

    All works fine on the live system, but if I try and make changes on my (remote) development system then I have difficulty as the Printer "connections" are specific to the live system and I keep getting prompted on the development system - "can't find Printer XXX do you want to change to the default printer". If I then transfer the development code to live then the printers are all messed up.

    This all seems to be controlled by - Reports("MyRep").Printer.DeviceName type properties, but the Printer property does not appear in the Report properties in the IDE.

    The only advice I have found it to set the printer using the Page Setup dialogue as part of the Print Preview in either Design or Layout view (in the IDE), but on the development machine the required printers are not available!!!

    I need a way to specify the Printer (DeviceName) in development mode, and be able to deploy the new version to Live without having to reconfigure 10+ reports (on the new Live version) each time I make a change to the code.

    Hope this makes sense

    Thanks again

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Could you not write some code to open each report and save the respective printer name and report.?
    Then assign report to your printer name.

    Reverse, before putting live?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    This may be relevant.

    Code:
    Option Compare Database
    Option Explicit
    ' ----------------------------------------------------------------
    ' Procedure Name: ListprinterInfo
    ' Purpose: To list info about Printers available
    ' Procedure Kind: Sub
    ' Procedure Access: Public
    ' Author: Jack
    ' Date: 17-Jul-21
    ' ----------------------------------------------------------------
    Sub ListprinterInfo()
    
    
              Dim prt As Printer
              Dim i As Integer
    10        For Each prt In Application.Printers
    20               i = i + 1
    30            With prt
    40                Debug.Print i & ":  Device name: " & .DeviceName & vbCr _
                          & "Driver name: " & .DriverName & vbCr _
                          & "Port: " & .Port & vbCrLf
    50            End With
    60        Next prt
    End Sub

    Here are a few printers available on my PC:
    ....
    4: Device name: Microsoft Print to PDF
    Driver name: winspool
    Port: PORTPROMPT:

    5: Device name: Fax
    Driver name: winspool
    Port: SHRFAX:

    6: Device name: Brother MFC-240C USB Printer
    Driver name: winspool
    Port: USB001

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Sounds like the need is to have the development db connect to local printer and the production db connect to other printers. Just because a property is not exposed in the property sheet does not mean it isn't available via code. Perhaps before opening report, you get the Application.CurrentPath property. Have never done this, but perhaps if it is not the production path, then set the property accordingly as in

    Dim prtDefault As Printer

    Set Application.Printer = Application.Printers(n) << where n is the index of the printer for a pc.

    If all production users connect to the same printer, perhaps use 0 for them, or you could have a table for printer index numbers specific to each user/station. You could load that value on app startup in a number of ways so that it doesn't have to be looked up every time you open a report. My laptop inkjet is (4), for example.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    TOPSie is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    101
    Quote Originally Posted by Welshgasman View Post
    Could you not write some code to open each report and save the respective printer name and report.?
    Then assign report to your printer name.

    Reverse, before putting live?

    Apparently not. Just tried this in the FormLoad

    With Reports("30PACKNEW")
    .Printer.DeviceName = "30PACK"
    End With

    Fails, with "can't assign to read-only property"

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 21
    Last Post: 05-18-2020, 09:42 PM
  2. Simple table relationships ("faces" to "spaces" to "chairs")
    By skydivetom in forum Database Design
    Replies: 36
    Last Post: 07-20-2019, 01:49 PM
  3. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  4. Replies: 0
    Last Post: 08-23-2013, 08:12 AM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 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