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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Parameter selection 1

Status
Not open for further replies.

Hm786

Programmer
Apr 5, 2001
88
US
Hi,

I created a crytal report with 5 input parameters. User can select any combination of the parameters. How do I code this in the record selection formula. For example if the user select parm1 and parm2 the report should pull only Parm1 and Parm2 related info. If they select only parm3 then the report need to pull only parm3 related info.

Please help me.

Thank You,
Hamida
 
In select statement you can use an If then else statement.

For example you may have a default value for Param1 as "Not Used", you statement would lokk something like

(If Param1 <> "Not Used" then Field1 = Param1 else true) and.....

The "else true" effectively means that no filter is applied when Param1 = Not Used

NB its important that each If then else is enclosed in brackets.

Ian
 
Ian,

What about the user select parm1 and parm2 or parm3 and parm4 how do I code. They want to select either one or multiple combination.

Thanks,
Hamida
 
YOu set all Parameters with the Default as Not Used.

Users can then enter filter data into either Param1 and 2 or Param3 and 4. Which ever pair are not used are left as default.

You must build an If then else statement for all 4 Params.

Ian
 
Users can't select only certain parameters, however they can elect NOT to change the parameters so add default values and code accordingly, akin to what Ian mentions.

So the example is:

As you create the parameters set the default value to "ALL" and code the record selection formula as:

(
if {?MyParm1} <> "All" then
{table.field} = {?MyParm1}
else
if {?MyParm1} = "All" then
true
)
and
(
if {?MyParm2} <> "All" then
{table.field} = {?MyParm2}
else
if {?MyParm2} = "All" then
true
)

So if they don't change anything for that parm it will not filter anything.

-k
 
Hi,

Using 'and' in the formula is not working. The parameters are for example contact, Phone, Firstname,Fax. If they enter contact 1 and then first name as'GROOM' I should get information for contact 1 and also for the First name 'GROOM'.

This my formula
(
if {?Cotact_Id}>0 then
{Command.Contact ID}={?Cotact_Id}
else

true
)
and
(
if len(({?ContLastName}))>0 then
{Command.Contact Last Name} = {?ContLastName}
else
true
)

Thanks,
Hamida
 
I do't think this will work,

if len(({?ContLastName}))>0 then
{Command.Contact Last Name} = {?ContLastName}
else
true

as {?ContLastName} will be null and that will cause formual o fail. Try doing as Synapse suggested. Where default of {?ContLastName} = All

Thus this part of formula will become

if {?ContLastName} <> "All" then
{Command.Contact Last Name} = {?ContLastName}
else
true

Ian
 
Ian,

Here is my formula
(
if {?Cotact_Id}>0 then
{Command.Contact ID}={?Cotact_Id}
else
true
)
and
(
if {?ContLastName}<> 'ALL' then
{Command.Contact Last Name} = {?ContLastName}
else
true
)
and
(
if {?Contact_FInitial}<> 'ALL' then
Trim({Command.Initials}) = uppercase({?Contact_FInitial})
else
true
)
and
(
if {?Cont_phone}<> 'ALL' then
Trim ({Command.Phone Number}) ={?Cont_phone}
else
true
)
and
(
if {?Cont_Fax}<> 'ALL' then
Trim ({Command.Fax Number}) ={?Cont_Fax}
else
true
)
and
(
if {?Cont_Email}<> 'ALL' then
Trim ({Command.E-Mail Address}) ={?Cont_Email}
else
true
)
Contact Lastname
3 KLEINDFIELDT
17 DERNER

If i enter contact 3 as my first parameter and
for lastname as Derner I should get above both rows.

Thanks,
Hamida
 
Ian and Synapse,

Thank you very much for your help and the report is working and I changed the code slightly and it worked.

(
if {?Cotact_Id}>0 then
{Command.Contact ID}={?Cotact_Id}
//--else
//--true
)
or

Thank You,
Hamida
 
Hi,
That would be true ONLY IF
The record with 'Derner' as a last name had Contact = 3
( It does not, obviously)

AND requires ALL parts to be True..

Try OR instead - if that meets your business need..

It will return a set of data made up of all records which match ANY of the several parameter values set,
(NOTE Use False instead of True and 'None' as the default parameter value to be sure it is clear what is being specified)
Like this maybe:
Code:
(
if {?Cotact_Id}>0 then
{Command.Contact ID}={?Cotact_Id}
else
False
)
OR
(
if {?ContLastName}<> 'None' then
    {Command.Contact Last Name} = {?ContLastName}
else
False
)
OR
(
if {?Contact_FInitial}<> 'None' then
    Trim({Command.Initials}) = uppercase({?Contact_FInitial})
else
False
)
OR
(
if {?Cont_phone}<> 'None' then
    Trim ({Command.Phone Number}) ={?Cont_phone}
else
False
)
OR
(
if {?Cont_Fax}<> 'None' then
    Trim ({Command.Fax Number}) ={?Cont_Fax}
else
False
)
OR
(
if {?Cont_Email}<> 'None'  then
    Trim ({Command.E-Mail Address}) ={?Cont_Email}
else
False
)

If that is what you want to do, that should do it..





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top