user3185925
user3185925

Reputation: 17

Access 2016 report header VBA

What I am about to ask is, I hope simple knowledge question.

The command 'CreateReport' in MS Access VBA creates a blank report draft. However, there are only page header and page footer. What I would like to achive is to create blank report draft which includes also report header and report footer. I could add them manualy after I create normal report draft, but then this is not what I want.

Is there any way to do it ?

Thank you all in advance.

Upvotes: 0

Views: 471

Answers (2)

Andre
Andre

Reputation: 27634

This works:

Sub TestReportCreate()

    Dim rpt As Access.Report

    Set rpt = Application.CreateReport
    ' report is created minimized
    DoCmd.Restore
    ' toggle Header/Footer ON
    Application.RunCommand acCmdReportHdrFtr

    ' Do something with the header
    rpt.Section(acHeader).BackColor = RGB(255, 192, 192)

End Sub

but using the ReportTemplate parameter may be easier.

Upvotes: 1

user3185925
user3185925

Reputation: 17

I have found a way out. What I did is I have created blank report with manualy added report header and footer, and used as a draft.

Upvotes: 0

Related Questions