Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Data selection in a Parameter Post Reply Post New Topic
Page  of 2 Next >>
Author Message
keiths
Newbie
Newbie


Joined: 18 Dec 2008
Location: United States
Online Status: Offline
Posts: 6
Quote keiths Replybullet Topic: Data selection in a Parameter
    Posted: 18 Dec 2008 at 9:10am

I would like to give the user the option of selecting a field in a parameter or printing all of the fields.  In other words, I want the user to be able to select one or multiple vendor names.  I can do that with the parameter.  However, if they left the parameter null or if I set up a selection of All, have the report select all of the vendor names.  Is there a way to do that?

 
Thanks for any help.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 19 Dec 2008 at 1:39pm
Try this in your selection criteria:
 
(IsNull({?Parameter}) or {table.field} = {?Parameter})
 
Notice that I put parentheses around this.  These are required if you have additional selection criteria, otherwise the selection filter won't work correctly.
 
-Dell
IP IP Logged
keiths
Newbie
Newbie


Joined: 18 Dec 2008
Location: United States
Online Status: Offline
Posts: 6
Quote keiths Replybullet Posted: 22 Dec 2008 at 7:07am
Thanks for your response.  However, the code did not work.  Whenever I run the report and leave the vendor name parameter null, it does not come back with any records.  But, whenever I select two or three vendor names, it brings back the records for those vendors.
 
Any other ideas?
 
Thanks again for any help.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 22 Dec 2008 at 9:10am

Do you have a default value set for the parameter?  If so, you'll have to use that instead of"IsNull()".   You might also try this:

(IsNull({?Parameter}) or {?Parameter} = "" or {table.field} = {?Parameter})

-Dell

IP IP Logged
keiths
Newbie
Newbie


Joined: 18 Dec 2008
Location: United States
Online Status: Offline
Posts: 6
Quote keiths Replybullet Posted: 22 Dec 2008 at 9:53am
Yes, there is a default parameter.  It is a list of about 400 vendor names.  The user wants to be able to pick and choose several vendor names or to be able to have the report run all of them.
 
I tried the additional code and it did not work either.
 
Thanks.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Dec 2008 at 2:41pm
You can set up a command to do this.
In your Database expert there is the Add Command option just above your DB source.
Double click the Add command and put the following code
 
SELECT FIELD (your vendor field that you want to select from here)
FROM table (the table your vendor field is in)
UNION
SELECT '...All'
 
In the Database Expert, Join this new command on the vendorname field to the vendor table on the vendor name field.
 
Point your Paramenter field to this command field instead of your vendor.vendorname.
 
Change your select expert to handle this with an if statement.
if {?Paramter}="...All" then
{Vendor.vendorname}={Command.field}
else {?Parameter}={Command.field}
IP IP Logged
keiths
Newbie
Newbie


Joined: 18 Dec 2008
Location: United States
Online Status: Offline
Posts: 6
Quote keiths Replybullet Posted: 23 Dec 2008 at 8:37am
Thank you very much DBlank.  That worked for what I was trying to do.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Sep 2009 at 6:46pm

as an addendum the select statement should be

{?parameter}="...All" or {?parameter}={table.field}
IP IP Logged
ishu1404
Newbie
Newbie


Joined: 03 Jan 2011
Location: India
Online Status: Offline
Posts: 12
Quote ishu1404 Replybullet Posted: 09 Jan 2011 at 7:41pm
hi DBlank,
 
 
I have already created a command objecta and linked it with the main table as specified. I have created a static prompt at the report level but the values fetched by the command object are not displayed in the Value-List in the prompt.
How to obtain the values fetched by the command object at the report level prompt?
 
Thanks
Ishu
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Jan 2011 at 4:12am
it should be a dynamic parameter pointing to the comman object field you wish to select from
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
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



This page was generated in 0.047 seconds.