Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if then statement to not run report

Status
Not open for further replies.

JetRamsey

Technical User
Oct 22, 2010
49
US
If the length of a character is not a minimum length of 3 characters for a parameter called Field1, I currently have this "Select Expert" statement.

if len({?Field1}) < 3 then {Comments.Comment} = "You did not enter a value" else
{Comments.Comment} like "*" &{?Field1}& "*"

However, is there a way not run the report if len({?Field1}) < 3 and at the same time put up an error message stating something like, "You need to enter more than two characters for Field1"?

BTW, the reason I'm stopping the report is to prevent someone from accidently calling for over 4 million records if they leave the parameter field blank or something like just the letter A, etc.
 
I think you should just add a criterion to the record selection formula like this:

(
len({?Field1}) >= 3 and
{Comments.Comment} like "*" &{?Field1}& "*"
)

-LB
 
Thanks for the reply. Just tried it, but the report still runs and takes 52 seconds to do so since it's crawling through millions of records. I was able to just put a label with a suppress rule on the report which states the error if the length is too short.

However, if possible, I would like the report to not run at all if the length is < 3 so that users don't take up the processing time.
 
What did you enter for {?Field}? It shouldn't have run at all if you entered a value with len < 3, since no records would meet the criteria. I just tested this, and when I looked at the "Show SQL Query" it returned a message:

"No SQL Query is used because the record selection formula returns no records."

I think you post the exact formula you used and also the results in report->show SQL query.

-LB


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top