Error loading report
Hello
I’m using a custom ReportExplorer, and sometimes — only occasionally — a report does not load. However, if I select another report in the same folder, it loads correctly.
Initially, I was loading the report using:
FReportExplorer.PrintPreview(FListView.ItemName, FListView.FolderId)
When the issue occurs, this call does nothing and no exception is raised.
I changed it to:
LoadReport(FListView.ItemName, FListView.FolderId)
With this method, an exception is raised indicating that the report cannot be found.
I’ve noticed that when this happens, FListView.FolderId has the value -1.
To work around this, I switched to loading reports using LoadFromDatabase, but the problem still occurs (although less frequently).
It's important to mention that I previously used Delphi 7 with an older version of ReportBuilder, and this issue never happened. The problem only started after upgrading to delphi 12.2 and the current version.
Do you have any guidance on why FolderId might intermittently be -1, or how to ensure reports load reliably in this scenario?
Thanks you
I’m using a custom ReportExplorer, and sometimes — only occasionally — a report does not load. However, if I select another report in the same folder, it loads correctly.
Initially, I was loading the report using:
FReportExplorer.PrintPreview(FListView.ItemName, FListView.FolderId)
When the issue occurs, this call does nothing and no exception is raised.
I changed it to:
LoadReport(FListView.ItemName, FListView.FolderId)
With this method, an exception is raised indicating that the report cannot be found.
I’ve noticed that when this happens, FListView.FolderId has the value -1.
To work around this, I switched to loading reports using LoadFromDatabase, but the problem still occurs (although less frequently).
It's important to mention that I previously used Delphi 7 with an older version of ReportBuilder, and this issue never happened. The problem only started after upgrading to delphi 12.2 and the current version.
Do you have any guidance on why FolderId might intermittently be -1, or how to ensure reports load reliably in this scenario?
Thanks you
Comments
This is not a known issue with the latest version of ReportBuilder.
As you mentioned, the issue appears to be when the FListView.FolderID is -1. ReportBuilder does not explicitly set the FolderID to -1 so it must be a specific case that causes the behavior.
Try using the built-in report explorer and see if the problem persists. If so, please create a simple example that demonstrates the issue and send it to us in .zip format and we'll research a solution. Send all files to support@digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
The issue is that the error occurs randomly, and I need to use a CustomReportExplorer. Is there any way to control the FolderId value?
Thank you
Or is there any other way to load the report by its Report ID?
thank you
Sorry, the one that has the value -1 is FListView.ItemId, although FListView.ItemName has the correct value and FolderId also has the correct value.
Thank you
Based on your description, it may be that the issue is only caused by new reports added while your application is open. In this case, it's possible the dataset is not refreshed and the ItemID is (temporarily) incorrect. Try setting the Item pipeline's RefreshAfterPost property to True and see if that helps the issue.
If the above doesn't help, take a look at the following article on how to locate a report from the Report Explorer without the use of the ItemID.
https://rbwiki.digital-metaphors.com/design/templates/how-to-programmatically-load-reports-saved-using-the-report-explorer/
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
The error does not occur with new reports; it always happens with existing ones. It can happen with any report: a report that displays correctly may fail to show the next time. I’m already using LoadFromDataBase, and although the error seems to happen less frequently, it still occurs, and honestly, it really confuses my clients. Since it’s a random error, I can’t reproduce it either.
I’ve checked that the report dataset is positioned correctly, but the error still appears.
Do you have any additional hints on what I could look into?
Is there any exception I can catch that might give me more information about why this is happening?