We need to make a Crystal Report pop up a custom error message and then stop running. Numerous Google searches have not even found anyone else asking how to do this before.
(The error is triggered to prevent the user from accidentally making a long running query that pegs the CPU on the database server. The report has no parameters, the third-party software appends filter criteria to the record selection formula.)
The best we have so far is:
NumberVar Zero := 0;
if InStr (RecordSelection, "IndexField", 1) <> 0
then 1
else 1/Zero // Force divide by zero error to stop report from running
This successfully halts the report, but displays the users the confusing "Divide by zero" error rather than an informative error message.
If we can't get an entirely custom error message, being able to customize part of the message might be an acceptable substitute.
The Crystal Report is run by a third party application, so we have to be able to trigger it entirely from within Crystal. We are using Crystal Reports Professional version 11.0.0.895.
I don't think the effort of writing a Crystal function library and deploying it to everywhere this runs is worth it, so this needs to be done using built-in Crystal functionality or other standard features available everywhere.