Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Display Parameter Value in Header up to 5 values. Expand / Collapse
Author
Message
Posted Thursday, May 16, 2013 10:01 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, February 7, 2014 1:45 PM
Points: 26, Visits: 266
Please See attached Image.
On my Report Have use 4 main parameter which I have to display all parameter value in text box before data display.
If user select nothing in doctor parameter we display by default "All" and if user pass value then display that parameter value in text box.

Now, I have little change from user they want to display parameter value in text box up to five and if they pass more that five then display message "More than Five Values Selected".

Please see attached image than better idea even I highlighted with red color .
even I also attached my custom code function which I am using to display values.and I tried to compare up to five but not helping out getting error. please check my below custom code
    Public Function FormatParamsAsTitle(strFacilityGroup as string, strFacility as string,  strVisitTypeGroup as string, strVisitType as string, strTeam as string, strDoc as string) as String
dim formattedFacility as string
dim formattedVisitType as string
dim formattedDoc as string
dim formattedTeam as string
dim Count as Integer
Count = 5

if strFacilityGroup = string.Empty and strFacility = string.Empty then
formattedFacility = "All"
elseif strFacilityGroup <> string.Empty then
formattedFacility = strFacilityGroup
else
formattedFacility = strFacility.Replace("'","").Replace(",",", ")
end if
formattedFacility = "Facility: " & formattedFacility & Environment.NewLine

if not string.IsNullOrEmpty(strVisitTypeGroup) then
formattedVisitType=strVisitTypeGroup
elseif strVisitType = string.empty then
formattedVisitType = "All"
else
formattedVisitType = strVisitType.Replace("'","") 'remove single quotes
end if
formattedVisitType = "Visit Types: " & formattedVisitType & Environment.NewLine

if strDoc = "" then
formattedDoc = "All"
else if count = strDoc.Count() then
formattedDoc = "More Than Five Values"
else
formattedDoc =strDoc.Replace("'","") 'remove single quotes
end if
formattedDoc = "Doctors: " & formattedDoc

if strTeam = "noDisplay" then
formattedTeam = ""
else
if strTeam = "" then
formattedTeam = "All"
else
formattedTeam = strTeam
end if
formattedTeam ="Teams: " & formattedTeam & Environment.NewLine
end if

FormatParamsAsTitle = String.Format("{0}{1}{2}{3}", formattedFacility, formattedVisitType, formattedTeam, formattedDoc)
End Function

and in report textbox expression


=Code.FormatParamsAsTitle(
iif(Parameters!facilityGroup.Value=string.Empty,"",First(Fields!FacilityGroupNames.Value, "dsFacilityGroup")),
iif(Parameters!facility.Value=string.Empty,"",First(Fields!FacilityNames.Value, "dsFacilityName")),
iif(Parameters!visitType.Value=string.Empty,"",First(Fields!VisitTypeNames.Value, "dsVisitType")),
iif(Parameters!visitTypeGroup.Value=string.Empty,"",First(Fields!VisitTypeGroupNames.Value, "dsVisitTypeGroup")),
iif(First(Fields!ConfigValue.Value, "dsConfigTeamDisplay").ToString()="false","noDisplay",
iif(Parameters!team.Value=string.Empty,"",First(Fields!TeamNames.Value, "dsTeam"))),
iif(Parameters!doctor.Value=string.Empty,"",First(Fields!DoctorNames.Value, "dsDocName")))




  Post Attachments 
Image1.png (4 views, 41.40 KB)
Post #1453646
Posted Friday, May 17, 2013 1:33 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, September 1, 2014 4:54 AM
Points: 26, Visits: 56
Hi zoom19,

I don't think there's an actual need to create custom code. I put the same logic into my reports using the following textbox expression:

= "Facility: " 
+ iif(Parameters!facilityGroup.Count = countrows("dsFacilityGroup")
, "All"
, iif(Parameters!facilityGroup.Count > 5
, format(Parameters!facilityGroup.Count) + " of " format(countrows("dsFacilityGroup")) + " selected"
, join(Parameters!facilityGroup.Label, ", ")
)
)


Hope this helps.
Kind regards,

Linda
Post #1453877
Posted Friday, May 17, 2013 7:04 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, February 7, 2014 1:45 PM
Points: 26, Visits: 266
Hi Linda and thanks to give me suggestion.
es You are correct we are using that way but I found another solution as well with custom code.

I am posted here might be it's useful for some one else.below I created another function which count character string then I used this in my main function.
Public Function CountCharacter(ByVal value As String, ByVal ch As Char) As Integer
Dim cnt As Integer = 0
For Each c As Char In value
If c = ch Then cnt += 1
Next
Return cnt
End Function

Below is My main function where I used my countcharacter function
 Public Function FormatParamsAsTitle(strFacilityGroup as string, strFacility as string,  strVisitTypeGroup as string, strVisitType as string, strTeam as string, strDoc as string) as String
dim formattedFacility as string
dim formattedVisitType as string
dim formattedDoc as string
dim formattedTeam as string
dim count as integer
Count = 5

if strFacilityGroup = string.Empty and strFacility = string.Empty then
formattedFacility = "All"
elseif strFacilityGroup <> string.Empty then
formattedFacility = strFacilityGroup
else
formattedFacility = strFacility.Replace("'","").Replace(",",", ")



if count <=CountCharacter( formattedFacility , ",")

formattedFacility ="More Than Five Facility Selected"
End if


end if
formattedFacility = "Facility: " & formattedFacility & Environment.NewLine

if not string.IsNullOrEmpty(strVisitTypeGroup) then
formattedVisitType=strVisitTypeGroup
elseif strVisitType = string.empty then
formattedVisitType = "All"
else
formattedVisitType = strVisitType.Replace("'","") 'remove single quotes


if count <=CountCharacter( formattedVisitType , ",")

formattedVisitType ="More Than Five Visit Type Selected"
End if


end if
formattedVisitType = "Visit Types: " & formattedVisitType & Environment.NewLine

if strDoc = "" then
formattedDoc = "All"
else
formattedDoc =strDoc.Replace("'","") 'remove single quotes


if count <=CountCharacter( formattedDoc , ",")

formattedDoc ="More Than Five Doctor Selected"
End if

end if
formattedDoc = "Doctors: " & formattedDoc

if strTeam = "noDisplay" then
formattedTeam = ""
else
if strTeam = "" then
formattedTeam = "All"
else
formattedTeam = strTeam.Replace("'","") 'remove single quotes

if count <=CountCharacter( formattedTeam , ",")

formattedTeam ="More Than Five Team Selected"
End if


end if
formattedTeam ="Teams: " & formattedTeam & Environment.NewLine
end if

FormatParamsAsTitle = String.Format("{0}{1}{2}{3}", formattedFacility, formattedVisitType, formattedTeam, formattedDoc)
End Function


Post #1453989
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse