Access reports save margin and portrait/landscape settings used the last time the report was produced. Those settings may have been changed due to hardware limitations or the default settings of the PC used to create the report. Or by user selection if you allow it. They will be used the next time the report is produced unless they must be changed TO LARGER MARGINS for the current hardware or defaults.
This is supposed to be a good thing as it facilitates portability between printers. You decide if it's worth it.
This usually means that someone produced the report with their Access default margins set to 1" all around. (That's the Access install default.) Then when you run it on your PC, those margins are acceptable and are USED instead of your default margins of, for example, .5" all around. At least that's what happened to me.
I'm trying to say this so it makes sense...
In short, margins of .5" cannot be enforced if the hardware or defaults when run require 1". However, if the report WAS previously run with margins of 1", that CAN and WILL be maintained the next time the report is run even if the hardware/defaults allow smaller margins.
Access makes sure that larger margin requirements are honored, but does not automatically resize for smaller margin capabilities.
If you want to force the settings you must do it in code.
This is documented in a Microsoft Knowledgebase article, but I cannot immediately find the number.
You'll need to create a VBA module and add event code for the report.
Good Luck!
Bob
P.S. This comes with my infamous 30/30 guarantee...
30 seconds/30 feet - whichever comes first.
Seriously, this is used live on a daily basis in my site.
Example code behind a Print Preview command button:
Private Sub RunPreviewReport_Click()
DoCmd.SetWarnings False
Call SetMargins("rptName", 0.5, 0.5, 0.5, 0.5)
'--ALL MARGINS 1/2 INCH
Call SetOrientation("rptName", True)
'--TRUE = PORTRAIT, FALSE = LANDSCAPE
DoCmd.Close acReport, "rptName", acSaveYes
DoCmd.SetWarnings True
DoCmd.OpenReport "rptName", acViewPreview
End Sub
VBA module:
Option Compare Database
Option Explicit
'--FOLLOWING USED TO SET PRINT ORIENTATION AND MARGINS AT RUN TIME, ENSURING CONSISTENCY
Type str_PRTMIP
strRGB As String * 28
End Type
Type type_PRTMIP
intLeftMargin As Long
intTopMargin As Long
intRightMargin As Long
intBotMargin As Long
intDataOnly As Long
intWidth As Long
intHeight As Long
intDefaultSize As Long
intColumns As Long
intColumnSpacing As Long
intRowSpacing As Long
intItemLayout As Long
intFastPrint As Long
intDatasheet As Long
End Type
Type str_DEVMODE
RGB As String * 94
End Type
Type type_DEVMODE
strDeviceName As String * 16
intSpecVersion As Integer
intDriverVersion As Integer
intSize As Integer
intDriverExtra As Integer
lngFields As Long
intOrientation As Integer
intPaperSize As Integer
intPaperLength As Integer
intPaperWidth As Integer
intScale As Integer
intCopies As Integer
intDefaultSource As Integer
intPrintQuality As Integer
intColor As Integer
intDuplex As Integer
intResolution As Integer
intTTOption As Integer
intCollate As Integer
strFormName As String * 16
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
Public Sub SetMargins(strName As String, sngLeft As Single, sngRight As Single, sngTop As Single, sngBottom As Single)
'-------------------------------
' strName = Report name
' sngLeft = Left Margin (in inches)
' sngRight = Right Margin
' sngTop = Top Margin
' sngBottom = Bottom Margin
'-------------------------------
Dim PrtMipString As str_PRTMIP
Dim PM As type_PRTMIP
Dim rpt As Report
DoCmd.OpenReport strName, acDesign
Set rpt = Reports(strName)
PrtMipString.strRGB = rpt.PrtMip
LSet PM = PrtMipString
PM.intLeftMargin = sngLeft * 1440
PM.intTopMargin = sngTop * 1440
PM.intRightMargin = sngRight * 1440
PM.intBotMargin = sngBottom * 1440
LSet PrtMipString = PM
rpt.PrtMip = PrtMipString.strRGB
End Sub
Public Sub SetOrientation(strName As String, boolPortrait As Boolean)
'-----------------------------
' strName = Report Name
' boolPortrait = Boolean...true = portrait, false = landscape
'-----------------------------
Const DM_PORTRAIT = 1
Const DM_LANDSCAPE = 2
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Dim strDevModeExtra As String
Dim rpt As Report
DoCmd.OpenReport strName, acDesign
Set rpt = Reports(strName)
If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
If boolPortrait Then
DM.intOrientation = DM_PORTRAIT
Else
DM.intOrientation = DM_LANDSCAPE
End If
LSet DevString = DM
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
End If
End Sub