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

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

Status
Not open for further replies.

jizzycrystal

IS-IT--Management
Nov 10, 2007
65
0
0
IE
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
 
(IF ISNULL({?Par1) then ({table.field} = {?Par2}) else ({table.field} = {Par1}))
 
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.
 
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???
 
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.
 
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
 
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!!
 
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

 
Got the parens wrong on the second example: if(hasvalue({?Business Group}) then {@businessgroup})
 
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}) )
 
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}+'*'
 
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?
 
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")
 
(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"
. . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top