access+training+london - printer change problems
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Access Training and help » access+training+london - Printer Change Problems

access+training+london - Printer Change Problems

The UK's most regular instructor-led training courses.
Training information: access+training+london · Access course microsoft training · Microsoft Access Training uk
See also · microsoft access training · access vba courses · access database course

resolvedResolved · Low Priority · Version Standard

Printer Change Problems

Martin has attended:
Access Advanced course
Access Intermediate course

by - delegate Martin [2 posts] (2007 Mar 22 Thu, 09:38) replyReply

I change my default printer for the application in VBA but the margins do not carry over to the new printer.

I use the Application.Printer.TopMargin = objOldPrinter.TopMargin but the value returned is always 0.

Any Ideas.

Thanks

Access Intermediate 1 day course
Version Date Location Places
available
Book Next place rate:
Card Invoice
2003 2008 Nov 25 Tue Bloomsbury 4 book now £207 £215
2002/XP 2008 Nov 26 Wed Tooting 0 FULL    
2003 2008 Dec 2 Tue Southwark 5 book now £198 £215
2007 2008 Dec 5 Fri Bloomsbury 4 book now £224 £224
2003 2008 Dec 9 Tue Bloomsbury 0 FULL    
2002/XP 2008 Dec 11 Thu Tooting 0 FULL    
Full Schedule: See all 55 Access Intermediate course dates.
Bookings currently available until 24th November 2009.

RE: Printer Change Problems

by - trainer Rich platinum contributer[744 posts] (2007 Apr 5 Thu, 13:13) replyReply

Hi Martin,

Sounds like objOldPrinter no longer exists? Make sure this is being assigned somewhere in your code. ie. print it out to the screen immediately after you set it. And then continue printing out the value further and further down your code until you get to the print command.

Also, couldn't you just set the margin in this line of code yourself? ie. if you know the margin was 2.6, couldn't you just have the code as:
Application.Printer.TopMargin = 2.6;

Let me know how you get on.

Regards, Rich

RE: Printer Change Problems

by - delegate Martin [2 posts] (2007 Apr 5 Thu, 20:10) replyReply

Thanks for the reply Rich. I dont think the old printer variable has gone out of scope. Here is the code I am using

Private Sub PrintReport(ByVal strPrinterName As String)
Dim objNewPrinter As Printer, objCurrPrinter As Printer, objP As Printer

For Each objP In Printers
If objP.DeviceName = strPrinterName Then
Set objNewPrinter = objP
Exit For
End If
Next

Set objCurrPrinter = Application.Printer
Application.Printer = objNewPrinter
With Application.Printer
.Orientation = objCurrPrinter.Orientation
.Duplex = acPRDPHorizontal
.LeftMargin = objCurrPrinter.LeftMargin
.RightMargin = objCurrPrinter.RightMargin
.TopMargin = objCurrPrinter.TopMargin
.BottomMargin = objCurrPrinter.BottomMargin
End With

DoCmd.OpenReport "rptRiskAssesment", acViewNormal

Application.Printer = objCurrPrinter

DoCmd.Close acForm, "frmPrintOptions"
End Sub

In a nutshell, it finds the printer based on the name passed to it and assigns it to a printer object. The actual application printer is stored in another printer object and replaced with the new printer. The margins, orientation and Duplex are passed to the new printer and the report is printed. Finally the old printer is replaced.

The orientation passes correctly but not the other settings. Does the printer carry margin settings or are these held in the report? One reason for the code to work like this is so that if he user selects the PDF printer option, the save as dialog pops up without them having to press to many buttons!

Many Thanks

RE: Printer Change Problems

by - trainer Rich platinum contributer[744 posts] (2007 Apr 10 Tue, 08:52) replyReply

Hi Martin,

I'll ask one of our VBA experts to have a look at this for you.

Regards, Rich

RE: Printer Change Problems

by - trainer Carlos gold contributer[479 posts] (2007 Apr 11 Wed, 09:50) replyReply

Martin

I have passed this on to my colleague Jacob for review.

Regards

Carlos


Related articles

· Reasons to Consider Microsoft Access Training
· Quick MS Access Training: Creating Custom Database Tables in 12 Simple Steps
· Access VBA Training Adds Power to your Databases
· Quick Access Course: Creating a Customer Contact Database in 8 Simple Steps
· Do You Have Trouble Understanding Databases? Consider a One-on-One Access Course

Access tip:

Prefixed Autonumbering

When using Date Type = Autonumber as a primary key, clients may require autonumbering to be prefixed with a letter.

For example, P001, where P is the prefixed letter

Instructions
Step 1. Create Field Name
Step 2. Set Data Type to Autonumber
Step 3. Within Field Property General tabsheet,
enter Format property as [backslash]P000



View all Access hints and tips

Institute of IT Training - Accredited Training Provider Microsoft Certified Partner
microsoft office
Microsoft Office Specialist Authorised Testing Centre (MOS and MCAS)

Prodigy Platinum Learning Partner

Institute of IT Training - Accredited Training Provider Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information

Training Articles

AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz