November 28, 2014 at 6:57 am
Hi
We have a user who wants to just case the First word in a string. For example, they have a field Event_Type which says Home Visit and they want it to say Home visit
I am able to get it to display all lowercase or all uppercase but cannot find anything that relates to just casing the first letter!
Any help would be much appreciated
Cheers
November 28, 2014 at 10:04 am
I don't know much about SSRS (other than spell it), but this could give you an idea.
=UCase(Left(Fields!Event_Type.Value)) & LCase(Right(Fields!Event_Type.Value, Len(Fields!Event_Type.Value) - 1))
November 28, 2014 at 10:33 am
Luis Cazares (11/28/2014)
I don't know much about SSRS (other than spell it), but this could give you an idea.
=UCase(Left(Fields!Event_Type.Value)) & LCase(Right(Fields!Event_Type.Value, Len(Fields!Event_Type.Value) - 1))
thanks, I'll give it a go
December 1, 2014 at 11:28 am
They can add code to the report in the report properties (I have provided an example below). I have done this before and it works. Let me know if you need any more help.
Public Function FirstWordUpper(ByVal word As String)
Dim newString As String = ""
Dim words()
words = word.Split(New Char() {" "c}, 2)
If words.Length > 1 Then
newString = UCase(words(0)) + " " + words(1)
Else
newString = words(0)
End If
Return newString
End Function
then in the field they want changed add the expression
=FirstWordUpper(Fields!Event_Type.Value)
December 4, 2014 at 8:24 am
Thanks to all who replied, neither scenario appears to work though π
December 4, 2014 at 8:46 am
shelts (12/4/2014)
Thanks to all who replied, neither scenario appears to work though π
Why not? If you get more details, you could get better answers. π
December 4, 2014 at 8:50 am
Luis Cazares (12/4/2014)
shelts (12/4/2014)
Thanks to all who replied, neither scenario appears to work though πWhy not? If you get more details, you could get better answers. π
Sorry, with your solution I got an error
The Value expression for the textrun βEvent_Type.Paragraphs[0].TextRuns[0]β contains an error: [BC30455] Argument not specified for parameter 'Length' of 'Public Function Left(str As String, Length As Integer) As String'.
at Microsoft.ReportingServices.Library.ReportingService2005Impl.SetReportDefinition(String Report, Byte[] Definition, Guid batchId, Warning[]& Warnings)
at Microsoft.ReportingServices.Library.ReportingService2010Impl.SetItemDefinition(String ItemPath, Byte[] Definition, String expectedItemTypeName, Property[] Properties, Warning[]& Warnings)
at Microsoft.ReportingServices.WebServer.ReportingService2010.SetItemDefinition(String ItemPath, Byte[] Definition, Property[] Properties, Warning[]& Warnings)
December 4, 2014 at 9:03 am
After talking with you briefly and understanding more this is what I came up with for anyone else that might need this.
Public Function FirstWordProper(ByVal word As String)
Dim newString As String = ""
Dim words()
words = word.Split(New Char() {" "c}, 2)
If words.Length > 1 Then
newString = UCase(words(0).ToString().Substring(0, 1)) + LCase(words(0).ToString().Substring(1, words(0).ToString().Length - 1)) + " " + LCase(words(1).ToString())
Else
newString = words(0)
End If
Return newString
End Function
December 4, 2014 at 9:06 am
HD_JOHN (12/4/2014)
After talking with you briefly and understanding more this is what I came up with for anyone else that might need this.Public Function FirstWordProper(ByVal word As String)
Dim newString As String = ""
Dim words()
words = word.Split(New Char() {" "c}, 2)
If words.Length > 1 Then
newString = UCase(words(0).ToString().Substring(0, 1)) + LCase(words(0).ToString().Substring(1, words(0).ToString().Length - 1)) + " " + LCase(words(1).ToString().Substring(0, 1)) + words(1).ToString().Substring(1, words(1).ToString().Length - 1)
Else
newString = words(0)
End If
Return newString
End Function
It works perfectly, thanks very much for your help
The expression needed to run it is
=Code.FirstWordProper(Fields!Event_Type.Value)
December 4, 2014 at 9:12 am
Yes, I made a mistake by not including the 2nd parameter of LEFT function. You should have been able to solve it by yourself.
=UCase(Left(Fields!Event_Type.Value,1)) & LCase(Right(Fields!Event_Type.Value, Len(Fields!Event_Type.Value) - 1))
December 4, 2014 at 9:15 am
Luis Cazares (12/4/2014)
Yes, I made a mistake by not including the 2nd parameter of LEFT function. You should have been able to solve it by yourself.
=UCase(Left(Fields!Event_Type.Value,1)) & LCase(Right(Fields!Event_Type.Value, Len(Fields!Event_Type.Value) - 1))
Thanks, this also works perfectly, I did try but couldn't figure it out for some reason. Thanks for your help
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply