well that's not new. Access crashes a lot. But I can't seem to find a workaround this time.
First of all, here's my situation. I have a big 11x17" report with 7 subreports that are identical in it. The only difference between the 7 subreports are some of the properties.
Now, when I want to modify one of those subreports, I have to apply the modification to every one of them, so it takes time.
Instead, I wrote a subroutine to copy every subreport, and change their properties accordingly.
I am capable of modifying most of the properties, but the only one that cannot be modified without a crash is RecordSource.
For some reason, I get a crash, or some weird error, depending on the situation.
here's my code: (the code is in a module, not in the report)
Public Function crash()
DoCmd.OpenReport "Report1", acViewDesign 'opens the report in design mode..
Report_Report1.RecordSource = "sometable"
End Function
as soon as it hits the second line, it crashes, but this time with a Visual C++ Runtime error dialog, which is weird... the error seems to have escaped access' unhandled exception catcher.
Consider the following code:
Public Function nocrash()
Dim ReportArray As Variant
Dim ReportArrayStr As Variant
Dim i As Long
ReportArray = Array(Report_Report1)
ReportArrayStr = Array("Report1")
For i = LBound(ReportArray) To UBound(ReportArray)
DoCmd.OpenReport ReportArrayStr(i), acViewDesign 'opens the report in design mode..
ReportArray(i).RecordSource = "sometable"
Next i
End Function
Access will not crash. It will give me a strange error:
"The Method 'RecordSource' of the object '_Report_Report1' has failed".
What's strange about this message is that the "Debug" button is disabled.
All that I can do is stop the execution.
Is there any workaround for this?
Oh yes, and one last thing. Some methods in access require the string name of a report, like:
DoCmd.Close acReport, "MyReport"
while some others need a reference to the report:
Report_MyReport.Caption = "Some Caption"
Would there be a way to get a reference to a report with its name, or get its name from its reference?
First of all, here's my situation. I have a big 11x17" report with 7 subreports that are identical in it. The only difference between the 7 subreports are some of the properties.
Now, when I want to modify one of those subreports, I have to apply the modification to every one of them, so it takes time.
Instead, I wrote a subroutine to copy every subreport, and change their properties accordingly.
I am capable of modifying most of the properties, but the only one that cannot be modified without a crash is RecordSource.
For some reason, I get a crash, or some weird error, depending on the situation.
here's my code: (the code is in a module, not in the report)
Public Function crash()
DoCmd.OpenReport "Report1", acViewDesign 'opens the report in design mode..
Report_Report1.RecordSource = "sometable"
End Function
as soon as it hits the second line, it crashes, but this time with a Visual C++ Runtime error dialog, which is weird... the error seems to have escaped access' unhandled exception catcher.
Consider the following code:
Public Function nocrash()
Dim ReportArray As Variant
Dim ReportArrayStr As Variant
Dim i As Long
ReportArray = Array(Report_Report1)
ReportArrayStr = Array("Report1")
For i = LBound(ReportArray) To UBound(ReportArray)
DoCmd.OpenReport ReportArrayStr(i), acViewDesign 'opens the report in design mode..
ReportArray(i).RecordSource = "sometable"
Next i
End Function
Access will not crash. It will give me a strange error:
"The Method 'RecordSource' of the object '_Report_Report1' has failed".
What's strange about this message is that the "Debug" button is disabled.
All that I can do is stop the execution.
Is there any workaround for this?
Oh yes, and one last thing. Some methods in access require the string name of a report, like:
DoCmd.Close acReport, "MyReport"
while some others need a reference to the report:
Report_MyReport.Caption = "Some Caption"
Would there be a way to get a reference to a report with its name, or get its name from its reference?