INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Parameters how do I allow a user to select one out of two parameters?

Parameters how do I allow a user to select one out of two parameters?

(OP)
I have set up two parameters and want to allow the user to select a value from either one or the other parameter but it is insisting that both parameters be selected. I have entered Par1 "OR" Par2 in the report selection but it is ignoring the "or" bit
Thanks

RE: Parameters how do I allow a user to select one out of two parameters?

(IF ISNULL({?Par1) then ({table.field} = {?Par2}) else ({table.field} = {Par1}))

RE: Parameters how do I allow a user to select one out of two parameters?

I do not believe that works properly. I believe you have to use the hasvalue function and the parameters need to be set as optional. I was running into the same issue a few months ago.

RE: Parameters how do I allow a user to select one out of two parameters?

(OP)
Thanks guys so I tried the if is null
(If is null ({?Business Unit} then ({nlmastm.nominal_code} startswith {?Business Group})
else
({nlmastm.nominal_code} startswith {?Business Unit}))
and it is saying it needs "one of the comparison operators <, ,=>. <= etc.

How do I use the hasvalue function or even better how do i make parameters optional???

RE: Parameters how do I allow a user to select one out of two parameters?

Basically the hasvalue function is a true/false return for a parameter (i.e., hasvalue({?someparmeter} , if the parameter has a value, then true). The parameter can be set to optional (I do not remember what version they added this feature), but it is available in Crystal Reports 2011. When you edit the parameter under the Value Options:, it is call Optional Prompt (default is False).

I hope this helps.

RE: Parameters how do I allow a user to select one out of two parameters?

(OP)
Thanks so much.
Yes on my new laptop where I have the later version CR 2013 I see it now.
So I set both to optional and entered the following to record selection
(IF not(hasvalue({?Business Unit}) = true) then ({nlmastm.nominal_code} startswith {?Business Group}) else true)

It works when I select from {?Business Group} but if I choose from my list in Business Unit it pulls all selections from this parameter not just the business unit I choose.
So almost there but not quite!
Any ideas

RE: Parameters how do I allow a user to select one out of two parameters?

(OP)
GOT IT!
(hasvalue({?Business Unit}) and

{nlmastm.nominal_code} startswith{?Business Unit})

OR

(hasvalue({?Business Group}) and

{nlmastm.nominal_code} startswith{?Business Group})

THANK YOU!!

RE: Parameters how do I allow a user to select one out of two parameters?

(OP)
SPOKE TOO SOON...I over simplified
the second parameter I want it to look to a formulae if it has a value not a field
so....

(hasvalue({?Business Unit}) and

{nlmastm.nominal_code} startswith{?Business Unit})

OR

if(hasvalue({?Business Group} then {@businessgroup}))

but crystal is not liking the syntax

RE: Parameters how do I allow a user to select one out of two parameters?

Got the parens wrong on the second example: if(hasvalue({?Business Group}) then {@businessgroup})

RE: Parameters how do I allow a user to select one out of two parameters?

Better way to do it is with one parameter for what to look for, and a second parameter with the value.

So for example {?Type of Search} would only have available values of Unit or Group
and {?Lookfor} would let you type in the Unit or Group to look for,

Then your select statement would look like:

(({?Type of Search = "Unit" and {table.bus_unit} = {?Lookfor})
or
({?Type of Search = "Group" and {table.bus_group} = {?Lookfor}) )

RE: Parameters how do I allow a user to select one out of two parameters?

This is how I do it in one of my reports. Both parameters are optional.

if hasvalue({?Vehicle Tag No}) then {Command.VehicleTagNo} like {?Vehicle Tag No}+'*'
else if hasvalue({?VIN}) then {Command.VehicleVinNo} like {?VIN}+'*'

RE: Parameters how do I allow a user to select one out of two parameters?

(OP)
Hi Kray It wasn't the parens unfortunately.
I then tried....
if hasvalue({?Business Unit}) then {nlmastm.nominal_code} startswith{?Business Unit}) like {?Business Unit}+'*'
else if hasvalue({?Business Group}) then {@businessgroup})
like {?Business Group}+'*'
Crystal doesn't like this. says remaining text (from "like") doesn't appear to be part of formula

I have to use a formulae for group as the value in the parameter group isn't a field or part of a field whereas the value in the business unit parameter is
Any other ideas?

RE: Parameters how do I allow a user to select one out of two parameters?

(OP)
Charliy thanks for you response too but I don't really under stand
(({?Type of Search = "Unit" and {table.bus_unit} = {?Lookfor})
or
({?Type of Search = "Group" and {table.bus_group} = {?Lookfor}) )

My formulae for group is like......
(if {?Business Group} = "AUDIT" THEN {nlmastm.nominal_code} STARTSWITH "D-1" OR
if {?Business Group} = "AUDIT" THEN {nlmastm.nominal_code} STARTSWITH "D-2"
OR
if {?Business Group} = "AUDIT" THEN {nlmastm.nominal_code} STARTSWITH "C-1"
OR
if {?Business Group} = "AUDIT" THEN {nlmastm.nominal_code} STARTSWITH "C-2")
OR
if ({?Business Group} = "TAX" THEN {nlmastm.nominal_code} STARTSWITH "L-1"
OR
if {?Business Group} = "TAX" THEN {nlmastm.nominal_code} STARTSWITH "L-2")

RE: Parameters how do I allow a user to select one out of two parameters?

(if {?Type of Search} = 'Group' and {?LookFor} = "AUDIT" and{ nlmastm.nominal_code} STARTSWITH "D-1"
else
if {?Type of Search} = 'Unit' and {?LookFor} = "AUDIT" and STARTSWITH "D-2"
. . .

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close