Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Lookup Table Post Reply Post New Topic
Author Message
Jonart
Newbie
Newbie


Joined: 02 Apr 2012
Online Status: Offline
Posts: 16
Quote Jonart Replybullet Topic: Lookup Table
     Posted: 30 Mar 2013 at 5:23am
The data in the first subreport looks something like this:

Apples
D1_______2
D2_______4
D3_______3
Apples____9

Lemons
D1_______6
D2_______2
Lemons___8

...and so on. There can be many categories of fruits.

In a second subreport I need a method for returning the total count for a given category of fruit. This sounds like a shared array, but I have no way of creating a subscript.

In other words, I need a virtual lookup table accessible to the second subreport. The single argument would be the Fruit ("Lemons") and the function would return the Count (8).

Fruit________Count
Apples________9
Lemons_______8
Etc.

Is there a way to accomplish this?

Jonart

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Apr 2013 at 3:03am
Can you create a stored proc...that would make life easier.
 
If you can't, how I would use the shared array would be to create 2 arrays. 1 for fruits and one for the total count of that fruit.  This way you can search the first for array for the fruit you want, and use its index to find the value in the second. 
 
Not as simple as I would like, but when you are limited to 1 dimensional arrays it's the best you can do.
 
You would probably want to have the ability to grow the array (unless you know the max number of fruits) in which case I would look at help for REDIM an array...PRESERVE will probably good a friend, since you don't the existing values erased when you increase the size of the array.
 
HTH
IP IP Logged
Jonart
Newbie
Newbie


Joined: 02 Apr 2012
Online Status: Offline
Posts: 16
Quote Jonart Replybullet Posted: 09 Apr 2013 at 4:53am
Thank you HTH. The two arrays occurred to me. It's messy but I guess I will have to do that.

I know nothing about stored procedures, but would like to learn. I will search this website and others for more information.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum