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

Crystal Reports XI Parameter Fields - Selecting Either Or

Status
Not open for further replies.

PWD

Technical User
Jul 12, 2002
823
GB
I have two Parameter Fields:-

Code:
{?Lookup type ref} & {?Lookup Code}
and this in the Selection Formulas; Record Selection:-

Code:
{LOOKUP.LOOKUP_TYPE_REF} = {?Lookup type ref} or  {LOOKUP.LOOKUP_CODE} = {?Lookup Code}
so that there is a choice of variables. This works OK if they choose from each variable. BUT if the user only wants to choose one of the variables it will only work if they choose something from the {?Lookup type ref}. If they attempt to not select from that field then the report just stalls on the ‘Enter Values’ window.

The {?Lookup type ref} is a ‘Number’ – it has to be – and the {?Lookup Code} is a String. I’ve tried reversing the order in the Record Selection.

Any ideas would be gratefully received.

Des.
 
Hi,
Depending on the CR version ( info that is good to specify when posting), a numeric parameter value must be supplied.
2 ways to handle it:

1:Create a default value for {?Lookup type ref} using a number never found in the data, like 0 or 999999.

2: Use a string and convert it in your formula:
Code:
{LOOKUP.LOOKUP_TYPE_REF} = {?Lookup type ref} or {LOOKUP.LOOKUP_CODE} = ToNumber({?Lookup Code})[COLOR=red] //could be an problem if no value is supplied, so a default value may still be needed as with the number type[/color]


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I would suggest adding prompt instructions like this:

If you wish to select based on type reference, select a type; otherwise select 0.

If you wish to select based on code, select a code; otherwise, select "None".

Then in your record selection formula use:

(
(
{?Lookup type ref} <> 0 and
{LOOKUP.LOOKUP_TYPE_REF} = {?Lookup type ref}
) or
(
{?Lookup Code} <> "None" and
{LOOKUP.LOOKUP_CODE} = {?Lookup Code}
)
)

-LB
 
Thanks chaps. It seems just using a value outside the given range for each type appears to work - without having to put in the extra check in the record selection formula. Nice. I've added the extra user instruction to the prompt, so let's see how it goes.

Thanks again,

Des.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top