G
Guest
I am trying to add code to a report module. This is a new imported report
without any prior modules in it.
The following line of code:
Modules("Report_" & ReportName).AddFromString str
Fails with Runtime Error 9 Subscript out of range.
If I open the report, add a dummy sub routine and then run the code it works
fine.
Here is the complete function:
Function AddCode(ReportName As String)
Dim str As String
str = "some_code"
DoCmd.OpenReport ReportName, acViewDesign
Application.Reports(ReportName).Visible = False
Modules("Report_" & ReportName).AddFromString str
Reports(ReportName).OnClose = "[Event Procedure]"
DoCmd.Close acReport, ReportName, acSaveYes
End Function
without any prior modules in it.
The following line of code:
Modules("Report_" & ReportName).AddFromString str
Fails with Runtime Error 9 Subscript out of range.
If I open the report, add a dummy sub routine and then run the code it works
fine.
Here is the complete function:
Function AddCode(ReportName As String)
Dim str As String
str = "some_code"
DoCmd.OpenReport ReportName, acViewDesign
Application.Reports(ReportName).Visible = False
Modules("Report_" & ReportName).AddFromString str
Reports(ReportName).OnClose = "[Event Procedure]"
DoCmd.Close acReport, ReportName, acSaveYes
End Function