Part III: More-Advanced Access Techniques
730
FIGURE 20.24
Vertical lines in rptVerticalLines help segregate data.
The syntax of the Line method is as follows:
object.Line (X1, Y1) - (X2, Y2)
The Line method requires four arguments. These arguments (X1, X2, Y1, and Y2) specify the top
and bottom (or left and right, depending on your perspective) coordinates of the line. Notice that
all calculated measurements on a report must be specified in twips (there are 1,440 twips per
inch). In this case, X1 and X2 are the same value and I’m forcing the line to start at the very top of
the Detail section ( 0 ) and to extend downward for 10,000 twips.
You might wonder why I’m using 10,000 as the Y2 coordinate for the end of the line. Access will
automatically “clip” the line to the height of the Detail section. Because the line control doesn’t
contain data, Access won’t expand the Detail section to accommodate the line you’ve drawn in
code. Instead, Access draws as much of the 10,000-twip line as needed to fill the Detail section,
and then it stops. The maximum value for Y2 is 32,767.
The same procedure could be used to draw horizontal lines for each section on the report. In the
report example (rptVerticalLines) in the database accompanying this chapter (Chapter20.
accdb), I’ve chosen to add line controls to the report instead. Using the Line control when the
height of the report section is fixed (for example, in the group header and footer) is simply faster
than drawing the line for each of these sections.