Line Method

Applies To

Report Object.

The Line method draws lines and rectangles on a Report object when the Print event occurs.

Syntax

object.Line [[Step](x1, y1)] - [Step](x2, y2)[, [color][, B[F]]]

You can use this method only in an event procedure or a macro specified by the event properties OnPrint or OnFormat for a report section, or OnPage for a report.

The Line method uses the following arguments.

Argument

Description

object

The Report object on which the line or rectangle is to be drawn.

Step

A key word that indicates the starting point coordinates are relative to the current graphics position given by the settings for the CurrentX and CurrentY properties of object.

x1, y1

Single values indicating the coordinates of the starting point for the line or rectangle. The Scale properties (ScaleMode, ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth) of object determine the unit of measure used. If this argument is omitted, the line begins at the position indicated by the CurrentX and CurrentY properties.

Step

A key word that indicates the end-point coordinates are relative to the line’s starting point.

x2, y2

Single values indicating the coordinates of the end point for the line to draw. These coordinates are required.


Argument

Description

color

A Long value indicating the RGB (red-green-blue) color used to draw the line. If this argument is omitted, the ForeColor property is used. You can also use the RGB function or QBColor function to specify the color.

B

An option that creates a rectangle using the coordinates as opposite corners of the rectangle.

F

F cannot be used without B. If the B option is used, the F option specifies that the rectangle is filled with the same color used to draw the rectangle. If B is used without F, the rectangle is filled with the color specified by the current settings of the FillColor and BackStyle properties. The default value for the BackStyle property is Normal for rectangles and lines.


Remarks

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.

See Also

Current X, Current Y Properties; DrawMode Property; DrawStyle Property; DrawWidth Property; Event Property; FillColor Property; FillStyle Property; ForeColor Property; Print Event; QBColor Function; RGB Function; ScaleHeight, ScaleWidth Properties; ScaleLeft, ScaleTop Properties; ScaleModel Property.

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 by clicking the New button on the Reports tab of the Database window. Set the OnPrint property of the Detail section to [Event Procedure]. Enter the following code in the report’s module, then switch to Print Preview.


Sub DrawLine()
    Dim rpt As Report, intColor As Integer
    Dim sngTop As Single, sngLeft As Single
    Dim sngWidth As Single, sngHeight As Single

    Set rpt = Reports!EmployeeReport
    rpt.ScaleMode = 3                    ' Set scale to pixels.
    sngTop = rpt.ScaleTop + 5            ' Top inside edge.
    sngLeft = rpt.ScaleLeft + 5            ' Left inside edge.
    sngWidth = rpt.ScaleWidth - 10        ' Width inside edge.
    sngHeight = rpt.ScaleHeight - 10        ' Height inside edge.
    intColor = RGB(255,0,0)                ' Make color red.
    ' Draw line as a box.
    rpt.Line(sngTop, sngLeft) - (sngWidth, sngHeight), intColor, BSub