SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Display Parameter Value in Header up to 5 values.


Display Parameter Value in Header up to 5 values.

Author
Message
zoom19
zoom19
SSC-Enthusiastic
SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)

Group: General Forum Members
Points: 114 Visits: 302
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")))



Attachments
Image1.png (7 views, 41.00 KB)
Linda Claes
Linda Claes
Valued Member
Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)

Group: General Forum Members
Points: 64 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
zoom19
zoom19
SSC-Enthusiastic
SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)

Group: General Forum Members
Points: 114 Visits: 302
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



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search