Click to See Complete Forum and Search --> : Dynamic Variable Names


vanny
10-10-2006, 01:11 AM
Is it possible to dynamically create variables as you need them.

Why I ask this is that in my reporting engine, I am looking at create the posibility to have TOT, AVG etc at the bottom of the groups as well as Grand Totals/AVG

But I dont know how many columns I will have to create them, I could bite the bullet and just allow for a maximum width of 50 columns, but I thought there could be a better way.

Sample Data Example

GROUP 1
TEST 1 4 5 3
TEST 1 4 5 3
TEST 1 4 5 3
TEST 1 4 5 3
TEST 1 4 5 3
---------------------
AVG 1 4 5 3


GROUP 2
TEST 2 4 5 3
TEST 2 4 5 3
TEST 2 4 5 3
TEST 2 4 5 3
TEST 2 4 5 3
---------------------
AVG 2 4 5 3

---------------------
OVERALL 1.5 4 5 3


Just before someone says why not use a Stored procedure, basically, every report is different, and I store my SQL in a table, then the engine I have written does all the formatting for me so far, All I have to do is pass a parrameter, so all I want to be able to say is AVG column 5, TOT column 2 etc. Oh and I am limited to Access databases. :(

jvanamali
10-10-2006, 02:02 PM
may be you can try storing in arrays

vanny
10-10-2006, 07:47 PM
I did think about arrays, but I dont think that you can use a variable in the declaration of size. Therefore I would have to keep re dimming them.

jvanamali
10-11-2006, 02:04 AM
Even if you have to redimension an array (asp supports redimensioning), it is better idea than creating so many variables