access+training+london - printer change problems
Microsoft Office TrainingThe UK's Number 1 for Microsoft Office Training Sitemap add this page to your favourites/bookmarksBookmark page
 
view a printable version of this pagePrintable version
Plus One Google
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

resolvedResolved · Low Priority · Version Standard

replyReplyThu 22 Mar 2007, 09:38Delegate Martin said...

Printer Change Problems

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

For upcoming training course dates see: Pricing & availability

replyReplyThu 5 Apr 2007, 13:13Trainer Rich said...

RE: Printer Change Problems

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

replyReplyThu 5 Apr 2007, 20:10Delegate Martin said...

RE: Printer Change Problems

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

replyReplyTue 10 Apr 2007, 08:52Trainer Rich said...

RE: Printer Change Problems

Hi Martin,

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

Regards, Rich

replyReplyWed 11 Apr 2007, 09:50Trainer Carlos said...

RE: Printer Change Problems

Martin

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

Regards

Carlos

 

 

Access tip:

How To Display An '&' In A Label In A Form

To have your label display a sentence with an &(ampersand) in it, like Fox & Hound simply type it as:

Fox && Hound

View all Access hints and tips

forum postI'm using Dsum and Daverage. Instead of listing the criteria in a column, is there a way to do it in a row?

Thanks,

James

» Forum post: DSum and DAverage


Rate this page:
2.2/5 (213 votes cast)
Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses
Microsoft Certified Partner
Security Seal verified by visa, mastercard securecard

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

Management training

Professional Skills courses
Project Management Course London
Project Management Courses London
Project Management Training London
Project Management Training
Project Seminar
Project Seminars
Time Management Course London
Time Management London
Time Management Courses London
Time Management Training London
Introduction to Finance course
Assertiveness Skills course
Effective Communications Skills training
Presentation Skills London

Training Formats

Public scheduled courses
On-site training
Closed company courses

Consultancy
Application Development

Blogs

Excel Training
MS Project Training
Microsoft Training Blog

Version differences

Office 2010 vs 2007
MS Project version differences

Training Information

London Computer Training
Computer Training London
Docklands Training Courses
Docklands Training London

Training venues London
Client list
FAQ
Pricing and availability
Course details / Syllabus

Training Articles
Training Information

Microsoft training

Microsoft Office training
& IT Applications

Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training
MS Project courses
MS Project training
Outlook courses
PowerPoint courses
PowerPoint training
VBA courses
Word courses
Microsoft.training
(more...)

Excel Training

Excel courses
Excel Training Courses Medway
Autonumber in Excel
Microsoft Excel training
Basic Excel Courses
Basic Excel Course
Basic Excel Training

Interested in MS Access training?

Access courses
Microsoft Access training
Microsoft access courses
Microsoft training access course
Microsoft+access+training
Access courses in london

Training provider

Training providers
IT training companies
IT training providers
Management Training providers
Management Training provider

Event history, feedback results
Events in 2012 · 2011 · 2010 · More

See also

Crystal Reports training