I tried different codes from different forums on how to change the printer but it intermittenly crashed in "application.printers"
Here are the codes I tried:
VERSION 1:===============================
Expand|Select|Wrap|Line Numbers
- Dim rpt As Report
- DoCmd.OpenReport "reportName", acViewPreview, , ,acHidden
- Set rpt = Reports("reportName")
- Set rpt.Printer = Application.Printers(strPrinterName)
- DoCmd.OpenReport "reportName", acViewNormal
- DoCmd.Close acReport, "reportName"
Expand|Select|Wrap|Line Numbers
- strDefaultPrt = Application.Printer.DeviceName
- Set Application.Printer = Application.Printers(strPrinterName)
- DoCmd.OpenReport "reportName", acViewNormal
- Set Application.Printer = Application.Printers(strDefaultPrt )
Expand|Select|Wrap|Line Numbers
- strDefaultPrinter = Application.Printer.DeviceName
- Call SetSpecificPrinter(strPrinterName)
- DoCmd.OpenReport "reportName", acViewNormal
- Call SetSpecificPrinter(strDefaultPrinter)
- Sub SetSpecificPrinter(tmpPrinterName)
- Dim prn As Printer
- Dim blnPrinterSet As Boolean
- For Each prn In Application.Printers
- If prn.DeviceName = tmpPrinterName Then
- Set Application.Printer = prn
- blnPrinterSet = True
- Exit For
- End If
- Next prn
- If Not blnPrinterSet Then MsgBox "Invoice Printer NOT found.", vbCritical
- Set prn = Nothing
- End Sub
Access 2010 crashed everytime it sees "application.printers"
Here's the error I got, or sometimes no error message at all:
"The exception unknown software exception (0xc0000417) occured in the application at location 0x785520f0"
When I hit OK button, application will be close.
Need suggestions on how to fix this intermittent error.... Please...
Thanks in advance!