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

I want to do this in my Record Sele

Status
Not open for further replies.

aaarthi

Programmer
Jun 2, 2003
21
US
I want to do this in my Record Selection formula. But it says the result must be boolean. Any work arounds?

StringVar selCustClass := "";
StringVar selCustClass2 := "";
StringVar selDocDate := "";
StringVar selDollarRangeMin := "";
StringVar selDollarRangeMax := "";


selDocDate = " AND ({pr_table.DOCDATE} IN Minimum({?DocumentDate}) To Maximum({?DocumentDate}) )";

IF Minimum({?DollarAmount}) > 0 THEN
selDollarRangeMin = " AND ({pr_table.CURTRXAM} >= Minimum({?DollarAmount})";
IF Maximum({?DollarAmount}) > 0 THEN
selDollarRangeMax = &quot; AND ({pr_table.CURTRXAM} <= Maximum({?DollarAmount})&quot;;


if {?ReportType} = &quot;D&O&quot; then
selCustClass = '({pr_table.CUSTCLAS} = &quot;200&quot; or {pr_table.CUSTCLAS} = &quot;210&quot; or {pr_table.CUSTCLAS} = &quot;800&quot; or {pr_table.CUSTCLAS} = &quot;220&quot;)'
else if {?ReportType} = &quot;XL&quot; then
selCustClass = ' ({pr_table.CUSTCLAS} = &quot;100&quot; or {pr_table.CUSTCLAS} = &quot;150&quot; or {pr_table.CUSTCLAS} = &quot;300&quot; or {pr_table.CUSTCLAS} = &quot;400&quot;'
else if {?ReportType} = &quot;All(Without BROKER)&quot; then
selCustClass = ' ({pr_table.CUSTCLAS} <> &quot;BROKER&quot;) '
else if {?ReportType} = &quot;BROKER&quot; then
selCustClass = ' ({pr_table.CUSTCLAS} = &quot;BROKER&quot;) '

//This is the final selection statement that I would like to have.
selCustClass + selDocDate + selDollarRangeMax;
 
First, don't use any variables in a record selection formula if you're constructing it within Crystal, it will prevent it from being passed to the database.

Rather than posting how you want to do something, why not post what needs to be done, it's possible someone may have a better means.

Also posting version information is always helpful and minimizes the amount of subsequent discovery.

What you probably want is something like:

(
IF Minimum({?DollarAmount}) > 0 THEN
{pr_table.CURTRXAM} >= Minimum({?DollarAmount})
and
{pr_table.CURTRXAM} <= Maximum({?DollarAmount})
)
and
(
if {?ReportType} = &quot;D&O&quot; then
{pr_table.CUSTCLAS} in [&quot;200&quot;, &quot;210&quot;, &quot;800&quot;, &quot;220&quot;]
else if {?ReportType} = &quot;XL&quot; then
selCustClass = {pr_table.CUSTCLAS} in [&quot;100&quot;, &quot;150&quot;, &quot;300&quot;, &quot;400&quot;]
else if {?ReportType} = &quot;All(Without BROKER)&quot; then
{pr_table.CUSTCLAS} <> &quot;BROKER&quot;
else if {?ReportType} = &quot;BROKER&quot; then
{pr_table.CUSTCLAS} = &quot;BROKER&quot;
)

It appears that you were trying to build a record selection from within VB or something, but it's difficult to know, as you shared nothing about the environment.

-k
 
Sorry about not explaining my problem in detail.

I am a VB programmer trying to do some reports in Crystal.

I am using Crystal 8.5 and am trying to form a record selection formula from within Crystal.

The problem is this.
I have 3 input parameters - ReportType, Document Date Range and Dollar Amount Range. Depending on whatever is selected by the user, I have to write the record selection formula.

I thought why not use it like what we would do in VB. That was when I wrote the above record selection formula.

But then when I saved it, it gave me an error saying that it expected a boolean. I wasn't very sure of how to do something like that in Crystal reports.

Your suggestion seems good. Let me try it and will let you know whether it worked.

Thanks!!


 
Ahhh, OK.

Using variables within VB is fine, however simplify your record selection to reflect the above, you should be fine.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top