Setting 2010 printer, outside of the report design mode (1 Viewer)

gblack

Registered User.
Local time
Today, 06:07
Joined
Sep 18, 2002
Messages
632
OK… after some investigation I have resolved an issue that was occurring in my Access application.

I have developed an SLA creation tool which is used by 80+ users. The end result/product is an SLA/contract (in the form of an Access report) that gets pushed out to SharePoint in pdf.

With the addition of MS Office 2010, some of my users, who have upgraded, were experiencing extra pages being printed out in the SLAs. Having run into this issue numerous times, I knew that it had to be a margins issue. The report(s) in question have left and right side margins setting of .25”.

When I investigated the issue, these users’ margins were .33”, so I changed them to .25” and saved, however Access 2010 would not let me save the print margins as such. This was supremely frustrating, until I realized that the print set up “default” printer doesn’t necessarily connect to an actual user's default printer. Often times the default setting is a generic printer setting which will not allow one of the side margins (I think left) to be anything less than .33”.

That said, once I change the “default” printer to an actual listed printer from the printer options, the report pushed out just fine.

Great, fantastic, now I know how to get my report to print right. The problem is: now I actually have to go into each report and change the printer setup print options and make sure they aren’t set to “default” and I must choose the appropriate printer. I never had to do this in MS Access 2007. This is incredibly problematic for me, being that I have 80+ users who run a split version of my MS Access app on a variety of Machines all over my organization (meaning differnt buildings/locations and such). Plus I am using an ACCDE file for each of the end users so they can’t actually open my Access file and and make any changes to the design of the report, mainly the printer settings themselves.

So, my question is: Is there a way that the user can go in and set up the print options, from outside of this specific MS Access.accde file, to ensure that all reports within said file will be connected to the appropriate printer, moreover print settings. Honestly, every printer I have chosen, to date, works just fine EXCEPT that stupid MS Office generic default.

Meaning can I somehow set up the reports printer, outside of the specific report's design?

Does anyone have any ideas?
 

MarkK

bit cruncher
Local time
Yesterday, 23:07
Joined
Mar 17, 2004
Messages
8,178
Yeah, you can write code that enumerates the Printers collection, locates a printer by name (or whatever), and sets this printer as the default printer for Access.
So you can write a function that returns a printer ...
Code:
Function GetPrinter(Name as string) As Access.Printer
  dim prt as printer
  for each prt in application.printers
    if instr(prt.name, Name) then 
      set GetPrinter = prt
      exit function
    end if
  next
  err.raise -1, "GetPrinter()", "Printer not found"
end function
And you can, before you print a report, change the printer ...
Code:
dim prt as printer
set prt = application.printer
set application.printer = GetPrinter("YourNonDefaultPrinterNameHere")
docmd.openreport "SomeReport"
set application.printer = prt
 

Daveyk01

Registered User.
Local time
Yesterday, 23:07
Joined
Jul 3, 2007
Messages
144
Code:
Function GetPrinter(Name as string) As Access.Printer
  dim prt as printer
  for each prt in application.printers
    if instr(prt.name, Name) then 
 
Right here I am getting an "Method or data member not found" error.

Thoughts? I need to able to set a specific printer before each report is opened.

I am converting database from Access 2000 to Access 2010. There is no longer the Snapshot format 8-( :mad:. So I must use the built-in PDF format, which is great, but the PDFs when created are formatted almost like in Landscape format, or looks like a blow up of a section of the report and not the whole report. Report looks great in preview mode, just not in PDF with the "DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, strFileName, True" command.

The code to set the default printer that worked so well in Access 2000 does not work in Access 2010 (running windows 7 also BTW).

Thanks for your help.

Dave

Thanks

Dave
 

MarkK

bit cruncher
Local time
Yesterday, 23:07
Joined
Mar 17, 2004
Messages
8,178
When this fails for you what is the value of the 'Name' parameter that you passed to the GetPrinter() function?
Other thoughts are, 1) have you referenced another object model that exposes a Printer object? If so, explicitly reference thobject model in the Dim statement, like ....
Code:
Dim prt as Access.Printer
Likewise, you may have written your own custom InStr() function, so qualify the references to that function, which is from VBA.Strings ...
Code:
IF VBA.Strings.InStr(prt.Name, Name)
Let me know if this helps,
Mark
 

mikewgr

New member
Local time
Today, 01:07
Joined
Nov 2, 2012
Messages
1
Code:
Function GetPrinter(Name as string) As Access.Printer
  dim prt as printer
  for each prt in application.printers
    if instr(prt.name, Name) then 
 
Right here I am getting an "Method or data member not found" error.
 
[/QUOTE]
 
In Access 2007 or 2010 it is:
 
if instr(prt.devicename, name) then
 
because there is no .name property of an application.printers
 

Users who are viewing this thread

Top Bottom