Report Object

Description

A Report object refers to a particular Microsoft Access report.

Remarks

A Report object is a member of the Reports collection, which is a collection of all currently open reports. Within the Reports collection, individual reports are indexed beginning with zero. You can refer to an individual Report object in the Reports collection either by referring to the report by name, or by referring to its index within the collection. If the report name includes a space, the name must be surrounded by brackets ([ ]).

Syntax

Example

Reports!reportname

Reports!OrderReport

Reports![report name]

Reports![Order Report]

Reports("reportname")

Reports("OrderReport")

Reports(index)

Reports(0)


Each Report object has a Controls collection, which contains all controls on the report. You can refer to a control on a report either by implicitly or explicitly referring to the Controls collection. Your code will be faster if you refer to the Controls collection implicitly. The following examples show two of the ways you might refer to a control named NewData on a report called OrderReport.

' Implicit reference.
Reports!OrderReport!NewData
' Explicit reference.
Reports!OrderReport.Controls!NewData
Properties

ActiveControl property, Application property, Caption property, Count property, CurrentRecord property, CurrentX, CurrentY properties, DateGrouping property, Dirty property, DrawMode property, DrawStyle property, DrawWidth property, Event properties, FastLaserPrinting property, FillColor property, FillStyle property, Filter property, FilterOn property, FontBold property, FontItalic, FontUnderline properties, FontName, FontSize properties, ForeColor property, Form, Report properties, FormatCount property, GridX, GridY properties, GroupLevel property, GrpKeepTogether property, HasData property, HasModule property, Height, Width properties, HelpContextID, HelpFile properties, hWnd property, LayoutForPrint property, Left, Top properties, MenuBar property, MinMaxButtons property, Module property, MoveLayout, NextRecord, PrintSection properties, Name property, OrderBy property, OrderByOn property, Page, Pages properties, PageHeader, PageFooter properties, Painting property, PaintPalette property, PaletteSource property, Parent property, Picture property, PictureAlignment property, PictureData property, PicturePages property, PictureSizeMode property, PictureTiling property, PictureType property, PrintCount property, PrtDevMode property, PrtDevNames property, PrtMip property, RecordLocks property, RecordSource property, ScaleHeight, ScaleWidth properties, ScaleLeft, ScaleTop properties, ScaleMode property, Section property, ShortcutMenuBar property, Tag property, Toolbar property, Visible property.

Methods

Circle method, DefaultControl method, Line method, Print method, PSet method, Scale method, TextHeight method, TextWidth method.

Events

Activate, Deactivate events, Error event, NoData event, Open, Close events, Page event.

See Also   Controls collection, Reports collection.

Example

The following example creates a new report and sets certain properties:

Sub NewReport()
    Dim rpt As Report

    ' Return variable of data type Report pointing to new Report object.
    Set rpt = CreateReport
    ' Set properties for new report.
    With rpt
        .RecordSource = "Products"
        .Caption = "Products Report"
    End With
    ' Restore new report.
    DoCmd.Restore
End Sub
The next example enumerates the Reports collection and prints the name of each report in the Reports collection. It then enumerates the Controls collection of each report and prints the name of each control on the report.

Sub AllOpenReports()
    Dim rpt As Report, ctl As Control

    ' Enumerate Reports collection.
    For Each rpt In Reports
        ' Print name of report.
        Debug.Print rpt.Name
        ' Enumerate Controls collection of each report.
        For Each ctl In rpt.Controls
            ' Print name of each control.
            Debug.Print ">>>"; ctl.Name
        Next ctl
    Next rpt
End Sub