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

Basic Array Question

Status
Not open for further replies.

steve053

Technical User
Oct 11, 2005
26
US
Crystal Reports v 10
SQL 2000

I need to create a sub report with some comparative data that is not in any table in our database. We may create a custom table in the future, but that decision will be based on the "merits" of this report.

I plan on using simple formulas for all of the related fields, however I would like to use an array as the basis of my detail.

Here is my array formula:
Code:
stringvar Array vNames:=
    makearray ("High","Average","Low");
numberVar i ;

For i := 1 to uBound (vNames)
Do
    (
    vNames = vNames[i];
    );

I would like to place this formula in the deatil section to create the 3 lines of data. The report returns "True" when I run it. I don't know where I am going wrong.

Any help is appreciated.
 
Since the database is SQL Server, you might use a UNION ALL in a command, such as:

select 'High' MyLevel from invoice
union
select 'Medium' MyLevel from invoice
union
select 'Low' MyLevel from invoice

Then you can join it to your existing tables in whatever way makes sense.

As for your way, you need to subscript each value, as in:

stringvar Array vNames:=
makearray ("High","Average","Low");
numberVar i ;
For i := 1 to uBound (vNames)
Do
(
vNames = vNames;
);
vNames[1]

Where 1 denotes thhe first value.

If you just want to display those 3 lines, create a formula of:

"High" & chr(13) & "Medium" & chr(13) & "Low" & chr(13)

place it anywhere.

-k
 
Thank you for your very timely reply.

I have no data in the SQL database to join my "high", "average", "low" too.

I tried
Code:
stringvar Array vNames:=
    makearray ("High","Average","Low");
numberVar i ;
For i := 1 to uBound (vNames)
Do
    (
    vNames = vNames[i];
    );
vNames[1]
and received one line "High"

I tried your formula
Code:
"High" & chr(13) & "Medium" & chr(13) & "Low" & chr(13)
and recieved one line "High"

I don't know what I'm doing wrong.
 
Check my post, "Where 1 denotes thhe first value."

If you want the next value, use vNames[1]

In the second formula, which is better, right click the formula and select format field->Can Grow

-k
 
Again synapsevampire, thank you for your reply and, more importantly, your patience.

I did this:
In the second formula, which is better, right click the formula and select format field->Can Grow

Which returned all three values on the same detail line.

I'm rally trying to output the following:

Detail1 High {formula} {formula]
Detail2 Ave {formula} {formula}
Detail3 Low {formula} {formula]

I know it's halfa$$, but I need to repeat a lot of putsy formatting and this seemed like the simplest way to go about it.

I'm sorry to be so dense but I really don't understand your previous post of:

"Check my post, "Where 1 denotes thhe first value."
If you want the next value, use vNames[1]"

I want to output each value on a seperate detail line.

Thanks again for your help.
 
Wht is {formula}

Sorry, my last post should have said:

"Check my post, "Where 1 denotes thhe first value."
If you want the next value, use vNames[2]"

The number 1 through 3 will denote which value you want.

I think that you need to stop and take the time to describe your intent, because it looks odd to me.

Post technical information, not descriptions:

Example data (what's coming from your database)
Expected output (what you intend to output based on the example data)

Why do you need to display this high. medium, low?

You can create formulas to display conditionally based on fields, as in:

if {table.field} = 1 then
"High"
else
if {table.field} = 2 then
"Medium"
else
if {table.field} = 3 then
"Low"

-k

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top