Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Return all if parameter is blank Post Reply Post New Topic
Author Message
bigburb
Newbie
Newbie


Joined: 07 Oct 2009
Location: United States
Online Status: Offline
Posts: 26
Quote bigburb Replybullet Topic: Return all if parameter is blank
     Posted: 29 Mar 2010 at 11:40am
How do I set up a selection formula so that a user can search for a range of part numbers, or they can leave both fields blank and view all part numbers in the database? CR11

Edited by bigburb - 29 Mar 2010 at 11:43am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Mar 2010 at 11:52am

Usually if you have a param it is required to input something. You choose what you want to equate to 'All' and then in the select expert you write it to use that definition.

Say it is numeric field and you want to use 0 for 'all'...
({?Param}=0 or {table.field} in minimum{?Param} to maximum{?Param})
 
Often people end up using a UNION command to insert an '...All' record for dynamic string params


Edited by DBlank - 29 Mar 2010 at 11:54am
IP IP Logged
bigburb
Newbie
Newbie


Joined: 07 Oct 2009
Location: United States
Online Status: Offline
Posts: 26
Quote bigburb Replybullet Posted: 29 Mar 2010 at 12:00pm
like this? {?ItemStart}='All' or {item.item} in {?ItemStart} to {?ItemEnd}
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Mar 2010 at 4:01am
Not quite.
You are using 2 params (Start and End) and they are numeric, correct?
Both field require that some value be entered. You have to tell your end users what to enter that is equivalent to 'All'. The value has to be of the same data type the param is (like zero for numeric). Then in the select expert you use an OR statement.
The first part of the OR just states the value you want to be 'All' = the param. This way when they user puts that value in it evaluates to TRUE and ignores the rest of the statement which means the select statement will not filter any data (or returns all rows).
The second part of your statement is what you want to it to do if the user does NOT enter the identified 'All' value (zero), like return values between two params. YOu end up with somehting like
 
{?ItemStart}=0 or {item.item} in {?ItemStart} to {?ItemEnd}
 
If the end user needs to be able to evaluate between 0 and an actual number then they would need to enter 0 in both start and end
 
({?ItemStart}=0 and {?ItemEnd}=0) or {item.item} in {?ItemStart} to {?ItemEnd}
 


Edited by DBlank - 30 Mar 2010 at 4:03am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum