access 2003 report printer properties

M

madhouse

This is driving me totally mad...

Am trying to allow user to select printer and its properties using VBA with
Access 2003. Have form that maintains table with printer device and popeties
such as orientation, colourmode, printquality, pappersize.
Immediately before calling DoCmd.OpenReport I call a sub to set the
Application.Printer to the saved print device and properties.
Immediately after calling DoCmd.OpenReport while the report is open and in
preview mode I call the same sub but this time to set the report's printer
and properties.
BUT it works VERY erratically and I cannot see why! HELP!!! Sometimes the
preview matches the properites and the printer dialog's properies match the
properites, othert times it does'nt! WHAT AM I DOING WRONG!

Main Code is:

.....
.....
SetPrintProperties Application.Printer
DoCmd.OpenReport "rptStatement", acViewPreview, , , acWindowNormal, SQL
Reports!rptStatement.Printer = Application.Printer
SetPrintProperties Reports!rptStatement.Printer
......
......

Sub Code is:
Sub SetPrintProperties(ByRef Prt As Printer)
Dim cnxn As ADODB.Connection
Set cnxn = CurrentProject.Connection
Dim SqlData As New ADODB.Recordset
Dim Prtloop As Printer

SqlData.Open "SELECT * FROM Printer;", cnxn, adOpenForwardOnly,
adLockOptimistic
For Each Prtloop In Application.Printers
If Prtloop.DeviceName = SqlData!PrinterDefault Then
Set Prt = Prtloop 'Application.Printers(SqlData!PrinterDefault)
Prt.Orientation = SqlData!PrinterOrientation
Prt.ColorMode = SqlData!PrinterColourMode
Prt.PaperSize = SqlData!PrinterPaperSize
Prt.PrintQuality = SqlData!PrinterQuality
Exit For
End If
Next Prtloop

SqlData.Close
Set SqlData = Nothing
Set cnxn = Nothing

End Sub
 
K

Klatuu

I'm not sure storing printer properties in a table is such a good idea. They
can change, particullary if you are using shared printers. Read up on the
PrtDevMode Property. It may be what you need.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top