Crystal Reports on the web

Looking at the huge number of links, my code snippets and samples that I've accumulated during my journey with Crystal Reports and Report Server (RAS), I've realized that something should be done with all that. So, for all who are struggling with similar problems I've faced while pursuing that elusive goal of putting Crystal Reports on the web, I will put as much information here as I can ...

Thursday, July 27, 2006

Picture function

Ever heard about picture function? No? Me neither until this very morning... No, it's at all not related to images. It's a STRING formating function...

Picture (string, picture)
Basic and Crystal syntax.

Arguments
String is a text string to be formatted according to the picture format.
Picture is a text string representing the way you want the characters in the string to be printed.
Return
string

Action
Picture (string, picture) prints a string or values in a text string in a predetermined format.

Typical Uses
Picture can be used to print a string "2065555555" in a telephone number format "(206) 555-5555", or to print other strings in fixed formats. If you are using a database field as the string, it will only work if the field is of a fixed and known length.

Note: You cannot use an asterisk as a wildcard in the picture argument. If you put an asterisk in the argument, it will show up as an asterisk in the resulting string.

Examples
The following examples are applicable to both Basic and Crystal syntax:

Picture ({customer.FAX},"(xxx) xxx-xxxx" )

Prints the values in the Fax field in the format (805) 555-5555, (313) 555-2555, and so on.

Picture ({customer.REGION}, "[xx]")

Prints the values in the Region field in the format [AK], [CA], and so on.

The size of the string you specify in the picture parameter, that is the number of x's you use, must be greater than or equal to the largest value of the string. So, for example, if you want to print city names in square brackets, you would do the following:

Picture ({customer.CITY}, "[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]")

This would print [Calgary],[Hamilton],[Toronto], and so on. The picture function trims to the size of the data in each row.

Note: The maximum number of x's that can be entered is 252.

Comments
Picture must be enclosed in quotes.
Use the character "x" in the mask to designate characters from the string.
If the database field includes brackets or other formatting, for example (xxx) xxx-xxxx, you will not be able to convert it to xxxxxxx. The parentheses and hyphen will still appear.

Thanks to Experts Exchange Sage called bdreed35 (http://www.experts-exchange.com/M_2620122.html) who pointed that one out...

Experts exchange is good site to find knowledgable people that can help with solving a problem ...
(http://www.experts-exchange.com/Databases/Crystal_Reports/)