Formatting Phone Numbers In Crystal Reports
I would think that formatting a phone number would be a pretty standard task in Crystal Reports so I’m not sure why this bit of information was so hard to find on the Internets. But anyway, for my own reference and maybe to help out someone else, here is how you do it. For the sake of version differences note that I am using Crystal Reports Version 10.
To format a raw data phone number:
Right click on Formula Fields option in the Field Explorer
Select Add New
Create a name for the Formula Field. I simply named mine Phone Number because there is only one phone number listed in the report, but as I better practice the name should have been more descriptive. Something like School Contact Phone Number would have been better.
Select User Editor
In the Formula Editor, paste the following code substituting table.field for your table and field.
/*
VB Syntax, Format Phone Number
*/
Picture (CStr ({table.field}), "(xxx) xxx-xxxx")
Save and close the Formula Editor
All that is left to do is drag the Phone Number Formula Field into your report in instead of the actual phone number field itself.
The Formula Fields Editor is a very powerful utility. While I’m on the topic, I’ve also found a great formula to page your reports in the same style we are all used to seeing in Microsoft Word.
/* Paging Numbers Formula */ NumberVar startNum := 0; "Page " + ToText((PageNumber + startNum), 0) + " of " + ToText((TotalPageCount + startNum), 0)














I am trying to teach myself how to do some basic things in Crystal. I have created a table, but the phone numbers need to be formatted. I have tried the formula above, but it is not working for me. I have Crystal Reports server 2008.
Hey Louise,
That is odd that this formula wouldn’t format the phone number for you. It’s a pretty standard formula as far as I understand.
The only potential issue I can think of off the top of me head would be that maybe the Picture method isn’t supported in Crystal Server 2008. I don’t know enough about the package to either confirm or deny this.
I’m not trying to insult your intelligence, but did you swap out the ‘table.field’ with the name of the table and field that contain the phone number value? I’ve made simple oversights like this myself countless times.
Thanks for this formula, it really helped my reports! It’s weird that there isn’t a more straightforward way to do this in Crystal