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

Parameter Field

Status
Not open for further replies.

ChrisH1

IS-IT--Management
Joined
May 23, 2006
Messages
36
Location
GB

Hi

Im using Crystal 8.

The report Im developing has 3 groups (in the following order)

Job
Workstage
Personnel

I want the user to be able to choose a workstage range but I would like the report to generate everything if the user chooses not to use this parameter.

How would I structure the parameter ?

Many Thanks

Chris



 
i would use a formula field where you put in something like:

if {?Workstage} = '' or isnull({?Workstage}) then 1=1
else {tablename.field} = {?Workstage}

 

Thanks that worked.

Could anyone please explain the 1=1 part of the formula

I get that the first part refers to the field being left empty or not returned but I dont quite see why the 1=1 is used here ?

 
No, it probably did not work, you just think that it does.

Create a default value for the parameter of "All" or some such, and then create a formula such as:

(
if {?Workstage} <> "All" then
{tablename.field} = {?Workstage}
else
if {?Workstage} = "All" then
true
)

Don't use Bloke's solution, at least not as constructed, null checks in Crystal MUST come first in a formula, and it's paritially redundant, closer would be:

(
if isnull({?Workstage})
or
{?Workstage} = "" then
{tablename.field} = {?Workstage}
else
(
if not(isnull({?Workstage}))
and
{?Workstage} <> "" then
true
)

As for 1=1, it has no purpose and can only serve to confuse the optimizer.

Also keep in mind that parameters act differently depending upon the report viewer in use and how it is invoked, you don't list technical information so you shouldn't expect technical responses.

-k
 

I used

if {?Workstage} <> "All" then
{tablename.field} = {?Workstage}
else
if {?Workstage} = "All" then
true

My record selection is now as follows

{SYJOBTRN.TRANS_TYPE} = "LAB" and
if{?Workstage } <> "*" then {SYJOBTRN.WORK_STAGE} = {?Workstage }
else if {?Workstage } = "*" then true
and
{SYJOBTRN.COMPANY} = "A" and
{SYJOBTRN.JOB} = {?Job Number}

The problem is it takes forever to read records.

Have I structured my record selcetion incorrectly ?
 
Have I structured my record selcetion incorrectly ?": Yes

Try:

(
{SYJOBTRN.TRANS_TYPE} = "LAB"
)
and
(
if {?Workstage } <> "*" then
{SYJOBTRN.WORK_STAGE} = {?Workstage }
else
if {?Workstage } = "*" then
true
)
and
(
{SYJOBTRN.COMPANY} = "A"
)
and
(
{SYJOBTRN.JOB} = {?Job Number}
)

Might want to read my FAQ on this topic:

faq767-3825

Anotehr method that may work is:

(
{SYJOBTRN.TRANS_TYPE} = "LAB"
)
and
(
{?Workstage } = "*"
or
{SYJOBTRN.WORK_STAGE} = {?Workstage }
)
and
(
{SYJOBTRN.COMPANY} = "A"
)
and
(
{SYJOBTRN.JOB} = {?Job Number}
)

-k
 
1 always equals 1 so it makes every row of data you are pulling in a valid one
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top