CurrentY Property [Access 2003 VBA Language Reference]
You can use the CurrentY property (along with the CurrentX property) to specify the horizontal and vertical coordinates for the starting position of the next printing and drawing method on a report.
expression Required. An expression that returns one of the objects in the Applies To list.
For example, you can use these properties to determine where the center point of a circle is drawn on a report section.
The CurrentY property specifies a Single value used in a numeric expression to set the vertical coordinate of the next printing drawing method.
The coordinates are measured from the upper-left corner of the report section that contains the reference to the CurrentX or CurrentY property. The CurrentX property setting is 0 at the section's left edge, and the CurrentY property setting is 0 at its top edge.
Use the ScaleMode property to define the unit of measure, such as points, pixels, characters, inches, millimeters, or centimeters, that the coordinates will be based on.
When you use the following graphics methods, the CurrentX and CurrentY property settings are changed as indicated.
|Method||Sets CurrentX, CurrentY properties to|
|Circle||The center of the object.|
|Line||The end point of the line (the x2, y2 coordinates).|
|The next print position.|
The following example uses the Print method to display text on a report named Report1. It uses the TextWidth and TextHeight methods to center the text vertically and horizontally.
Private Sub Detail_Format(Cancel As Integer, _ FormatCount As Integer) Dim rpt as Report Dim strMessage As String Dim intHorSize As Integer, intVerSize As Integer Set rpt = Me strMessage = "DisplayMessage" With rpt 'Set scale to pixels, and set FontName and 'FontSize properties. .ScaleMode = 3 .FontName = "Courier" .FontSize = 24 End With ' Horizontal width. intHorSize = Rpt.TextWidth(strMessage) ' Vertical height. intVerSize = Rpt.TextHeight(strMessage) ' Calculate location of text to be displayed. Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2) Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2) ' Print text on Report object. Rpt.Print strMessage End Sub