No report header using CreateReport?

K

kylenix

I programmatically created a report by using CreateReport()
But when I tried to add a label control to the report header, errors
occured.

Dim rpt As Access.Report
Dim lbl As Access.Label

Set rpt = CreateReport
Set lbl = CreateReportControl(rpt.Name, acLabel, acHeader)

Run-time error '2148':
the number you used to refer to the form or report section is invalid.

When I changed acHeader to acPageHeader, everything is fine.

It seems to me that the report header is not enabled when the report is
created by CreateReport() call.

Is there any way to dynamically create a report with report header?

Thanks
 
D

Duane Hookom

This is a fairly substantial undertaking. Normally I would work with an
existing report and just move or hide/show controls on an existing report.
However, you might want to save a report that has a Report Header section
with the name "Normal".
 
J

Jeff Conrad

Add this line right before the CreateReportControl line:

DoCmd.RunCommand acCmdReportHdrFtr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top