Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Can you do a lookup table/array in crystal? Post Reply Post New Topic
Author Message
cruser2
Newbie
Newbie


Joined: 07 Feb 2012
Online Status: Offline
Posts: 14
Quote cruser2 Replybullet Topic: Can you do a lookup table/array in crystal?
     Posted: 25 Sep 2012 at 5:13am

ConfusedHi here is a challenge for you:

 

I am trying to create a type of lookup in my report. To use as code inside a formula (can I mix crystal and VB script in the same report)?

I have a main SQL that reads all records and is used for the main detail. However I have another table I wish to use to group the types of results into different buckets depending on the records category.

To attempt to explain more simply imagine I have a restaurant, you can have either 1 of 3 options of a Starter, Main, or Desert. Call this lookup table X. Then depending on which of these options you select you either get a Soup, Steak, or a Jelly lookup table Y.

First of all I need to load these lookup tables when the report first opens.So I have Lookup table X containing ‘STARTER,’MAIN’,’DESERT’. And lookup table Y = ‘SOUP’,’STEAK’,’JELLY’. They each havean index? Value 1,2, and 3.

 

When the user runs the report they select which course they want, eg MAIN

 

Next I create another formula that uses these lookups.

Imagine I am processing each record from a stock /inventory table and depending on the user parameter it will check if MAIN course (which will be STEAK) is in the inventory table.

So my formula may look like the below (note this is no syntax but something that could exist):

If TABLE_INVENTORY.ITEM = (item from lookup Y index (table X = Parmater1) then ‘YES’.

So since I selected MAIN as my parameter it check to see if there is STEAK in the inventory.

I hope this makes sense and if you can suggest how I might go about this in Crystal would be very useful.

 

Thanks,

JD.

 

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 26 Sep 2012 at 7:14am
CR doesn't really 'lookup' values in a table, it displays the matching rows.
 
so, if you built individual tables using Command objects and then built a table of all the possible combinations (which doesn't sound like fun), and you linked all the tables together...which link back to inventory (I'm guessing) then as your user selects the options, which can cascade, you would end up selecting 1 row in a table and everything would link from there.
 
what you are looking for, at least this is my take on it, is really a program.  CR doesn't search through tables to find a match.  You might be able to 'trick' it perhaps, but it would be alot of arrays, and arrays are not very helpful in CR, at least that is what i would try to do.
 
Building the tables might be an easier option, which would be my first thought.  The cascading of parameters wouldn't be too hard, I think. Once you have the parameters, I would think that a stored proc could easily check the inventory.
 
I know, I've thrown alot of ideas, hopefully 1 makes sense to you.
 
HTH
IP IP Logged
cruser2
Newbie
Newbie


Joined: 07 Feb 2012
Online Status: Offline
Posts: 14
Quote cruser2 Replybullet Posted: 27 Sep 2012 at 12:12am
Hi, yep, when I said table I meant more of an array function (enumeration type object).
My background if software dev so trying to make crystal work like a program is frustrating.
I tried the array objects but didnt seem anyway to return the index argument.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 27 Sep 2012 at 4:53am
yeah, if you are used to programming, CR can be very frustrating.  The only way that I can explain it is that you need to get all your data at one time.  I tend to use stored procs to return a 'super' row of all the data that I will need, but you can easily break it up into multiple tables (select) from the stored proc and link those.
 
CR will only get the data once per report (subreports being 'different' reports are constantly hitting the database).
 
HTH
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