all groups > sql server reporting services > november 2004 >
You're in the

sql server reporting services

group:

Parameter key/value list in the actual report?


Parameter key/value list in the actual report? Jonas Montonen
11/1/2004 2:28:45 PM
sql server reporting services:
We are in need of a visualization of all parameters (about 16 of them)
for our reports. (When a cutstomer prints a report, we need to have the
parameters (mostly filterering input) values available)

Is there a way if "looping" the Parameters Collection, creating a String
or populate a table with the parameter/value pairs?

We tried to create a string by looping the Report.Parameters object in
the "Code" section, but it is not a collection so we failed there.

Also tried to access the parameters "by index". Looping until we fails,
but it seems you cant access the paremeters by index :(

The solution we have is to create a table with a field for each
parameter. But this is a non dynamic and non generic solution. A bit of
worl work too for our 25+ reports with about 10-15 parameters each.

Anyone out there have a solution for this problem?

Regards
Re: Parameter key/value list in the actual report? Lev Semenets [MSFT]
11/1/2004 9:54:39 PM
JFYI, parameters can be accessed by name, i.e.
=Parameters("Param1").Value (same as =Parameters!Param1.Value)
Or even =Parameters(Field!A.Value).Value

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

Re: Parameter key/value list in the actual report? Jonas Montonen
11/2/2004 9:06:51 AM
[quoted text, click to view]
Yes, that we know.

What I want is to be able to (programmatically) loop all parameter and
there values, appending them to a tring and display that string in the
report.

So if I add a parameters, I will not have to update the logic for
displaying the parameter values.

Re: Parameter key/value list in the actual report? Jonas Montonen
11/2/2004 10:35:56 AM
[quoted text, click to view]

As a workaround I'm trying another funtion in the Code section.
But I would like to have a identical function in each report... so some
parameter could be missing.

Is there a way of refering/checking if a parameter exists and not get
the error ??
Eg:
IF(not Report.Parameters("PARAM_THAT_ARE_MISSING") is nothing) then
.
.
End if

This line generates this error today :(
"The value expression for the textbox ‘textbox2’ contains an error: The
expression referenced a non-existing parameter in the report parameters
collection."

FYI:
- Textbox2.Value: "=Code.getParametersHeader()"
- PARAM_THAT_ARE_MISSING is a parmeter that is not present in the actual
report (Dummy to trigger this error)

// Regards Jonas Montonen

Function getParametersHeader()
Dim retString
Dim parCount
Dim newLine
Dim ParamsPerLine

ParamsPerLine = 3
parCount = 0

If(Report.Parameters("Pop").Label <> "") then
parCount = parCount +1
newLine = getParamNewLine(parCount, ParamsPerLine)
retString = retString + newLine + "Pop: " +
Report.Parameters("Pop").Label
end if

if(Report.Parameters("Measure").Label <> "") then
parCount = parCount +1
newLine = getParamNewLine(parCount, ParamsPerLine)
retString = retString + newLine + "Pop: " +
Report.Parameters("Pop").Label

end if

if(Report.Parameters("TimeType").Label <> "") then
parCount = parCount +1
newLine = getParamNewLine(parCount, ParamsPerLine)
retString = retString + newLine + "Time Type: " +
Report.Parameters("TimeType").Label
end if

if(not Report.Parameters("PARAM_THAT_ARE_MISSING") is nothing) then
parCount = parCount +1
newLine = getParamNewLine(parCount, ParamsPerLine)
retString = retString + newLine + "PARAM_THAT_ARE_MISSING: " +
Report.Parameters("PARAM_THAT_ARE_MISSING").Label
end if

Return retString
Re: Parameter key/value list in the actual report? Jonas Montonen
11/2/2004 12:21:21 PM
[quoted text, click to view]

Not very nice... there must be a better way.

Usage:
TextFieldXX.Value "=Code.getParametersHeader(5, "Pop,AgreementType,
ServiceLevel, CRAZY_PARAM_THAT_DOES_NOT_EXIST")

Function getParametersHeader(paramsPerRow, daWantedParams)
Dim myArray() As String = Split(daWantedParams, ",")
Dim RetVal As String
Dim newLine As String
Dim parCount As Integer
Dim paramsPerLine

ON ERROR RESUME NEXT

For Each curParam As String In myArray ' Iterate through elements.
If(Report.Parameters(curParam.ToString()).Label <> "") then
newLine = getParamNewLine(parCount, paramsPerRow)
RetVal += newLine + curParam.ToString() + ": " +
Report.Parameters(curParam.ToString()).Label
parCount += 1
end if
Next

Return RetVal
End Function

Function getParamNewLine(countValue, valuesPerRow)
if((countValue mod valuesPerRow) = 0) then
return vbcrlf
else
if((countValue mod valuesPerRow) = 1) then
return " "
else
return " | "
end if
end if

Re: Parameter key/value list in the actual report? Lev Semenets [MSFT]
11/3/2004 10:12:14 PM
I'm afraid that is not supported. But I think it is possible to do
indirectly, using custom assemly.

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

AddThis Social Bookmark Button