Senin, 23 Februari 2015

[MS_AccessPros] Re: SetUp Printer Settings in a Report via VBA MS Access 2013

 

Norbert


here is what I'd do. Create a table that has fields for the report name and the printer. Then write a function that loops through the table and sets the report's printer device name.



Public Function CheckRptPrinter()
'Purpose  : Check all reports to see if printer is set correctly.
    Dim rpt As Report
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strSQL As String
    Dim strPrinter As String
    
    Set db = CurrentDb
    strSQL = "SELECT RptName, PrinterName FROM tblRptPrinters"
    Set rs = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
    
    With rs
        Do While Not .EOF
            DoCmd.OpenReport !RptName, acViewDesign
            Set rpt = Reports(!RptName)
            strPrinter = !PrinterName
            rpt.Printer = Application.Printers(strPrinter)
            Set rpt = Nothing
            'Save and close report.
            DoCmd.Close acReport, !RptName, acSaveYes
            
            .MoveNext
        Loop
    End With

    Set rs = Nothing
    Set db = Nothing

    MsgBox "Report printer setup complete.", vbInformation

End Function

Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
Microsoft Office Access MVP
http://mvp.microsoft.com/en-us/mvp/Bill%20Mosca-35852
My nothing-to-do-with-Access blog
http://wrmosca.wordpress.com

 



---In MS_Access_Professionals@yahoogroups.com, <drnorbert@msn.com> wrote :

I have 4 printers for reports:

Default-

Checks-(Legal)

Label-(Dymo printer)

Duplex


When I make a change in my computer in a particular report and save it the printer properties change back to the Default printer.

The same happens if I imported all the objects of the database to a new database.

Also if I use FMS total Access Analyzer or Detective all the reports  settings change to the Default printer.


Therefore when I upload the database to the production program at the office I need to setup again many  reports to the corresponding printer. (about 235)

 

The solution will be if I can hard code the printer settings using perhaps PrtDevMode property however I am not very familiar how to apply this property or other to my issue.


Thanks 

Norbert  

__._,_.___

Posted by: wrmosca@comcast.net
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

.

__,_._,___

Tidak ada komentar:

Posting Komentar