The following example uses the Line method to draw a red rectangle five pixels inside the edge of a report named EmployeeReport. The RGB function is used to make the line red.
To try this example in Microsoft Access, create a new report. Paste the following code in the declarations section of the report's module, then switch to Print Preview.
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
' Call the Drawline procedure
DrawLine
End Sub
Sub DrawLine()
Dim rpt As Report, lngColor As Long
Dim sngTop As Single, sngLeft As Single
Dim sngWidth As Single, sngHeight As Single
Set rpt = Reports!EmployeeReport
' Set scale to pixels.
rpt.ScaleMode = 3
' Top inside edge.
sngTop = rpt.ScaleTop + 5
' Left inside edge.
sngLeft = rpt.ScaleLeft + 5
' Width inside edge.
sngWidth = rpt.ScaleWidth - 10
' Height inside edge.
sngHeight = rpt.ScaleHeight - 10
' Make color red.
lngColor = RGB(255,0,0)
' Draw line as a box.
rpt.Line(sngTop, sngLeft) - (sngWidth, sngHeight), lngColor, B
End Sub