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

Record Selection with an Array

Status
Not open for further replies.

ProgressiveJL

IS-IT--Management
Jul 5, 2006
46
0
0
CA
Hi all,

Using CR XI and trying to select records based on values in an array.

I'm getting the following error message "An array's dimension must be an integer between 1 and 1000 when I execute the following formula:

numberVar array itemtypes;
numberVar counter;

if {?VAULT_DEPOSITS} = true then
(
counter := counter + 1;
redim preserve itemtypes [counter];
itemtypes [counter] := 9
);
if {?VAULT_REBOOT} = true then
(
counter := counter + 1;
redim preserve itemtypes [counter];
itemtypes [counter] := 28
);

Any suggestions?
 
Why are you trying to use this method to acquire values from a parameter?

And this formula isn't selecting any records,it's simply trying to build an array.

I think that youmisunderstand basic technical terms, so instead of trying to dexribe things, post example data and the expedcted output.

To select values based on a multivalue parameter, go to Report->Selection Formula->Record and try:

{table.field} = {?MyParameter}

-k
 
Sorry for the poor description.. let me try again..

I'm ultimately trying to select the records based on user inputs. I've used boolean values to control whether or not records with specific values will be included in the report.

I think I've been able to complete this task except for when the user decides to display all records or only records for a specific employee.

Example Scenario:

User chooses {?MONEY_REMOVE} to be true and checks {?TEAM_ALL} to be false and enters an employee name into {?TEAM_ID}

The result should show all records with itemtype = 23 and measure = 1 for the inputted employee name ie. {?TEAM_ID}

CODE:

numberVar array itemtypes;
numberVar array measures;
numberVar counterItem := 0;
numberVar counterMeasure := 0;

if {?MONEY_REMOVE} = true then
(
counterItem := counterItem + 1;
counterMeasure := counterMeasure + 1;
redim preserve itemtypes [counterItem];
redim preserve measures [counterMeasure];
itemtypes [counterItem] := 23;
measures [counterMeasure] := 1
);
if {?MONEY_REMAIN} = true then
(
counterItem := counterItem + 1;
counterMeasure := counterMeasure + 1;
redim preserve itemtypes [counterItem];
redim preserve measures [counterMeasure];
itemtypes [counterItem] := 23;
measures [counterMeasure] := 0
);
if {?DEPOSIT} = true then
(
counterItem := counterItem + 1;
redim preserve itemtypes [counterItem];
itemtypes [counterItem] := 9
);
if {?REBOOT} = true then
(
counterItem := counterItem + 1;
redim preserve itemtypes [counterItem];
itemtypes [counterItem] := 28
);

// selection for entire vs individual team member doesn't work
if {?TEAM_ALL} = false then {items01.employee} = {?TEAM_ID} and {items01.itemtype} in itemtypes and
// default measure is 0
if ubound(measures) = 0 then {items01.measure} = 0 else {items01.measure} in measures and
// user selects period to report on
selectDateRange({items01.tdate}, {?DATE_START}, {?DATE_END})

Let me know if my 2nd try is still unclear...
Thanks!
 
The use of variables in the record selection will generally prevent that part from being passed to the database.

Move your array collection to a formula that buildsout a string or some such.

I'd want to revise the architecture here as it's too complex for such simple rules.

-k
 
Thanks for the insight K! Helpful as always...

I removed my formula from "Select Expert Formula" and created a custom function accordingly to clean it up. As for the employee selection problem:

if teamAll = true then true else employee = teamID

Thanks again!
Until next time... Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top