Left, Top Properties

Applies To

Bound Object Frame Control, Chart Control, Check Box Control, Combo Box Control, Command Button Control, Image Control, Label Control, Line Control, List Box Control, Option Button Control, Option Group Control, Page Break Control, Rectangle Control, Subform/Subreport Control, Text Box Control, Toggle Button Control, Unbound Object Frame Control.

Description

You can use the Left and Top properties to specify an object’s location on a form or report. For example, you might want a control to be always aligned at the upper-right corner of a section.

Setting

A control’s location is the distance measured from its left or top border to the left or top edge of the section containing the control. Setting the Left or Top property to 0 places the control’s edge at the very left or top of the section. To use a unit of measurement different from the setting in the Regional Settings section of the Windows Control Panel, specify the unit, such as cm or in (for example, 3 cm or 2 in).

In Visual Basic, use a numeric expression to set the value of this property. Values are expressed in twips.

For controls, you can set these properties using control’s property sheet, a macro, or Visual Basic.

For reports, you can set these properties only in an event procedure while the report is in the Print Preview window or being printed.

Remarks

When you move a control, its new Left and Top property settings are automatically entered in the property sheet. When you view a form or report in Print Preview or when you print a form, a control’s location is determined by its Left and Top property settings along with the margin settings in the Print Setup dialog box.

For reports, the Top property setting is the amount the current section is offset from the top of the page; the Left property setting is the amount the current section is offset from the left edge of the page. Both property settings are expressed in twips. You can use these properties to specify how far down the page you want a section to print in the section’s Format event procedure.

Note To set the bottom and right margins, use the Height and Width properties.

See Also

Height, Width Properties.

Example

The following example checks the Left property setting for the current report. If the value is less than the minimum margin setting, the intNextRecord and intPrintSection variables are set to False (0).


Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)conLeftMargin = 1880intNextRecord As Integer, intPrintSection As Integer
' Don't advance to next record or print next section
' if Left property setting is more than 1880 twips.
    If Me.Left < conLeftMargin Then
        intNextRecord = False
        intPrintSection = False
    End IfSub