sttting report margins on print

G

Guest

I would like to set the report page margins on print to .25
here is the code for the print button I am using it uses the current record
log


Dim StrWhere As String
StrWhere = "[LOG]= """ & Me!Log & """"
DoCmd.OpenReport "DELIVERY ORDER", acViewPreview, , StrWhere
DoCmd.PrintOut acPages, 1, 1
DoCmd.Close acReport, "DELIVERY ORDER"
 
G

Guest

Hi Terry,

You can use the Printer object in Access to set margins etc. see example
code below.

Dim Ptr As Printer

'To use a specific printer
Set Ptr = Application.Printers(strDeviceName)
'To use the default printer
Set Ptr = Application.Printer


'Now you can set all you need to for the printer object Ptr
'The 56.7 is to convert mm to Twips as the printer settings are measured
in Twips (1/1440 of an inch)
'In this example the settings are read from a recordset rsPrinterSettings
With Ptr
.PaperBin = 15
.DefaultSize = False
.PaperSize = lngPaperbin
.BottomMargin = rsPrinterSettings!Bottom * 56.7
.LeftMargin = rsPrinterSettings!Left * 56.7
.RightMargin = rsPrinterSettings!Right * 56.7
.TopMargin = rsPrinterSettings!Top * 56.7
.RowSpacing = rsPrinterSettings!RowSpacing * 56.7
.ItemsAcross = rsPrinterSettings!ItemsAcross
.Orientation = rsPrinterSettings!Orientation
.Copies = 1
If Left(Docname, 6) = "Labels" Then
.DefaultSize = False
.ItemSizeHeight = rsPrinterSettings!Height * 56.7
.ItemSizeWidth = rsPrinterSettings!Width * 56.7
End If
If Docname = "RptNewRegistration" Then
.Duplex = acPRDPHorizontal
Else
.Duplex = acPRDPSimplex
End If
End With

Hope this will get you going.

Ger
 

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