Hello, I need to programmatically create a report in MS Access 2000 via Visual Basic code. I am having trouble getting at the report's "Report Header" and "Report Footer". For example, the following code
Dim rpt As Report
Set rpt = CreateReport
Dim strReportName as String
strReportName = rpt.Name
Dim lbl As Label
Set lbl = CreateReportControl(strReportName, acLabel, acHeader)
generates run-time error 2148: "The number you used to refer to the form or report section is invalid". The error is tripped by the last line. If I change acHeader to acPageHeader, then everything works fine (except that the label is created in the page header rather than the report header).
I think the problem is that the report header/footer is not "visible" or "created" yet. But I do not know how to create these in VBA without using a report template, which I would like to avoid.