expression.Line(flags, x1, y1, x2, y2, color)
expression Required. An expression that returns one of the objects in the Applies To list.
flags Required Integer.
x1 Required Single. The value indicating the coordinate of the starting point for the line or rectangle. The Scale properties (ScaleMode, ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth) of the Report object specified by the object argument determine the unit of measure used. If this argument is omitted, the line begins at the position indicated by the CurrentX property.
y1 Required Single. The value indicating the coordinate of the starting point for the line or rectangle. The Scale properties (ScaleMode, ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth) of the Report object specified by the object argument determine the unit of measure used. If this argument is omitted, the line begins at the position indicated by the CurrentY property.
x2 Required Single. The value indicating the coordinate of the end point for the line to draw. This argument is required.
y2 Required Single. The value indicating the coordinate of the end point for the line to draw. This argument is required.
color Required Long. The value indicating the RGB (red-green-blue) color used to draw the line. If this argument is omitted, the value of the ForeColor property is used. You can also use the RGB function or QBColor function to specify the color.
Remarks
You can use this method only in an event procedure or a macro specified by the OnPrint or OnFormat event property for a report section, or the OnPage event property for a report.
To connect two drawing lines, make sure that one line begins at the end point of the previous line.
The width of the line drawn depends on the DrawWidth property setting. The way a line or rectangle is drawn on the background depends on the settings of the DrawMode and DrawStyle properties.
When you apply the Line method, the CurrentX and CurrentY properties are set to the end point specified by the x2 and y2 arguments.
Example
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 named EmployeeReport. 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