Thursday, September 22, 2005

Phone Format Sql Reporting Services

Here is how to format a phone number in Sql Reporting Services:

call the function below with this in an expression box: =code.CustomFormat( Fields!ContactNumber.Value)

Put this in the Custom Code dialog box:


Public Function CustomFormat(ByVal Value As String) As String

Dim FormatPhone As String
FormatPhone = Trim(Value)
IF FormatPhone <> VBNullString Then

Select Case FormatPhone.Length
Case 7
FormatPhone = FormatPhone.Insert(3, "-" )
Case 10
FormatPhone = FormatPhone.Insert(3, "-" )
FormatPhone = FormatPhone.Insert(7, "-" )
Case 12
FormatPhone = FormatPhone.Insert(3, "-" )
FormatPhone = FormatPhone.Insert(7, "-" )
Case Else
FormatPhone = ""
End Select
End If

Return FormatPhone

End Function


Thanks to the post here: http://www.sqlreportingservices.net/Ask/3647.aspx

No comments:

Post a Comment