I was searching for a way to display the description of a parameter. The only solution I found, that I could understand, was in this thread. Based on that thread I did the following:
- Created a parameter that has a list of 35 values. Examples of those values:
- 0-ALL
- 100026-CCH5
- 100025-CCH6
- 0-ALL
- Created two formulas:
- Formula 1 - Placed on the Report Header; works very well.
- BeforeReadingRecords;
- numberVar counter;
- stringVar display;
- for counter := 1 to Count({?Unit}) do
- (
- if {?Unit}[counter] = '0-ALL' then
- display := 'ALL'
- else
- if counter = 1 then
- display := MID({?Unit}[counter],8)
- else
- display := display + ', ' + MID({?Unit}[counter],8)
- );
- display;
- Formula 2
- BeforeReadingRecords;
- numberVar UnitsCounter;
- numberVar Array SelectedUnits;
- Redim SelectedUnits[35];
- for UnitsCounter := 1 to Count({?Unit}) do
- (
- if {?Unit}[UnitsCounter] = '0-ALL' then
- SelectedUnits[UnitsCounter] = 99
- else
- if UnitsCounter = 1 then
- SelectedUnits[UnitsCounter] = ToNumber(LEFT({?Unit}[UnitsCounter],6))
- else
- SelectedUnits[UnitsCounter] = ToNumber(LEFT({?Unit}[UnitsCounter],6))
- );
- ToText(SelectedUnits[2]); //This line is for debugging to see if array is correctly built. Formula placed on RH or Detail get the same results
- Formula 1 - Placed on the Report Header; works very well.
- Created Record Selection Formula
- WhileReadingRecords;
- numberVar Array SelectedUnits;
- {command.Patient Age} >= 18
- AND ({command.DepartmentID} IN SelectedUnits or 99 in SelectedUnits
ISSUE
No matter where I place Formula 2 I get no results because the Global Variable Numeric Array is always empty.
- Putting the code of Formula 2 in the Record Selection does not work, as well.
- Hard coding values in line 11 and line 13 of formula 2 confirms that the issue is not the functions being used to assign a value to an entry in the array
- I confirmed that the data being selected does exist in my SQL Server database.
- I cannot use a Shared variable in the Record Selection because the formula must run while reading records
- I placed the following formula (Formula 3) in detail section to confirm the contents of the array
- WhilePrintingRecords;
- numberVar ArrayIndex;
- numberVar Array SelectedUnits;
- stringVar DisplayArray;
- for ArrayIndex := 1 to Count(SelectedUnits) do
- (
- if ArrayIndex = 1 then
- DisplayArray := DisplayArray + ToText(SelectedUnits[ArrayIndex],0,"")
- else
- DisplayArray := DisplayArray + ', ' + ToText(SelectedUnits[ArrayIndex],0,"")
- );
- DisplayArray;
- Here is a screen shot of the report results
- Why won't this work? Is there a better way?