Unanswered: Accessing a Report Object in Access using VBA
I am having a major problem acessing a Report within an Access project by using code. I am getting the following error:
Run-time error 2457. The number used to refer to the report is invalid.
The ways that I am trying to refer to the report, which is called rptReport, are:
(a). MsgBox CurrentProject.AllReports.Application.Reports(0).N ame
(b). MsgBox Access.Application.Reports("rptName").Name
(c). MsgBox MsgBox Reports.Item(0).Name
I have tried about 10 different ways of trying to do this and I cannot get this to work. Could someone please help. This is kind of urgent.
BTW - just realised what you have tried -
there are two types of "report" you can access in code -
The code I have posted looks in the Reports Container - this contains all the persistent (saved) reports.
is a Collection of all the open reports. As such the index is dynamic and changes over time (the first report opened is 0 and subsequent ones count up - if a report is closed the reports are reindexed).