Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2002
    Posts
    1

    Unanswered: Creating/accessing report header/footer

    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.

    Does anyone have any ideas on this?

    Thanks very much.

    - Matt

  2. #2
    Join Date
    Dec 2003
    Posts
    1
    drmatt, be sure that you have the reportheader/footer showing on your design view of the report. That should resolve the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •