Active Topics Memberlist Search Help | |
Register Login |
Programming | |
EXP Systems Forum : PDF reDirect : Programming |
Topic: Acess Report set to "Use Specific Report" | |
Author | Message |
David_Carle
Newbie Joined: 26 May 09 Posts: 36 |
Topic: Acess Report set to "Use Specific Report" Posted: 28 Jun 10 at 4:14PM |
I have been investigating a problem that a customer has whereby some Access 2003 reports that previously worked with PDF reDirect now go to the printer instead of PDF Emailing. In the past I have resolved this by recreating the report, believing there to be some corruption in the report.
However, after doing this today (a tedious process, but it did work), I started thinking about the Printer for [ReportName] option within File - Page Setup - Page tab.
Am I correct in thinking that this option MUST be set to "Default Printer" (rather than "Use Specific Printer") in order to work with PDF reDirect?
(It would make sense, given the code you supply that saves, sets and resets the default printer). This would also explain why when I recreate a report from scratch it works OK - because it would be set to Default Printer.
If this is the case, can you suggest a way to save the report setting of a report before changing it to Default Printer (in code), then setting it back after printing to BatchPDF?
The reason for this is that my customer uses many printers (eg different types of stationery) and needs to configure the reports to go to the appropriate printer.
Many thanks for any suggestions.
|
|
IP Logged | |
Michel_K17
Moderator Group Forum Administrator Joined: 25 Jan 03 Posts: 1673 |
Posted: 29 Jun 10 at 1:04AM |
Hi,
Please check the VBA code in the Access sample file. There is code in there for setting the default printer for Access 2000, which should not be required for Access 2003. The code shows how I switch the logic for older versions of Access. What you can do is to amend the code to set the default printer as shown for the Access 2000 code. Here is the function in the code you should be looking at, and modifying. I hope this helps: Private Function PrintOutputToBatchPrinter(ByRef MyDocumentName As String, ByRef MyBatchPrinter As String) As Boolean Dim oDefaultPrinter As Printer Dim DefaultPrinter As String On Error GoTo Error_handler '------------------------------------------------------------- ' Switch (temporarily) the current Active printer with our Batch Printer '------------------------------------------------------------- ' Explanation: Access (2003 and beyond) supports the "ActivePrinter" object, ' but older versions of Access (97, 2000) can only print to the "default" printer. If Val(Application.Version) >= 11 Then ' Access 2003 or 2008 Set oDefaultPrinter = Application.Printer Application.Printer = Application.Printers(MyBatchPrinter) Else ' Older Access version: we need to switch the default printer manually (temporarily). ' Note: the driver might be "PDF reDirect v2" or "PDF reDirect Pro" but code below ' is most likely to be correct DefaultPrinter = GetDefaultPrinter() Err.Clear If Not SetDefaultPrinter(MyBatchPrinter & ",PDF reDirect Pro v2,PDF_REDIRECT_PORT:") Then ' Could not set the Batch Printer oPDF.LastErrorNumber = Err.Number oPDF.ErrorLastDLL = Err.LastDllError oPDF.LastErrorDescription = "Could not set the Batch Printer as the output printer." GoTo Error_handler End If End If '------------------------------------------------------------- ' Create the PDF by sending the Print Job to the Batch Printer '------------------------------------------------------------- ' Note: I received a report from someone who was having a problem ' printing his Access report. The first few records were being ' repeated/duplicated on the second page. Although I did not figure ' out why this problem occured, I was able to fix the problem by ' generating a "Preview" first before printing. (see below) DoCmd.OpenReport MyDocumentName, acViewPreview ' Generate a Preview First DoCmd.OpenReport MyDocumentName, acViewNormal ' Print the Report ' Done. Recover memory DoCmd.Close acReport, MyDocumentName '------------------------------------------------------------- ' Return the Active Printer to the original one '------------------------------------------------------------- If Val(Application.Version) >= 11 Then ' Access (2003 and beyond) supports the "ActivePrinter" object If Not oDefaultPrinter Is Nothing Then Application.Printer = oDefaultPrinter Else ' Older Access version: Restore the original default printer SetDefaultPrinter DefaultPrinter End If PrintOutputToBatchPrinter = True Error_handler: End Function |
|
Michel Korwin-Szymanowski
EXP Systems LLC |
|
IP Logged | |
David_Carle
Newbie Joined: 26 May 09 Posts: 36 |
Posted: 29 Jun 10 at 2:09AM |
Hi Michel Thanks for your response, but that's not what I'm meaning. Rather than setting the default printer for Windows, I'm asking about changing the setting for the report (within File - Page Setup - Page tab) between "Default Printer" and "Use Specific Printer" within code. Or, to put it another way, how would one use PDF reDirect with an Access report that has been set to "Use Specific Printer"?
|
|
IP Logged | |
Michel_K17
Moderator Group Forum Administrator Joined: 25 Jan 03 Posts: 1673 |
Posted: 29 Jun 10 at 11:33PM |
Hi,
I really think that it's done via the Application.Printer object. From an Application.Report object, you can query the name of the printer (DeviceName), but I do not believe it can be set, and have to use Application.Printer. Cheers! Michel |
|
Michel Korwin-Szymanowski
EXP Systems LLC |
|
IP Logged | |
Forum Jump |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |