Wednesday, August 1, 2012

Crystal Reports : Data and Text

You can actually insert data fields into text fields onto your report. This helps make text fields look "cleaner". We'll use a Starting Date and Ending Date as an example:

You'd like to have the text "From {Starting Date} to {Ending Date}" on the report header.

Step #1 : Create an empty text field and insert it onto the report.
Step #2 : Insert both the Starting Date and Ending Date fields onto the report.
Step #3 : Click into the text field and type in "From ". Make sure you type a space at the end.
Step #4 : Now drag the Starting Date field directly onto the text field. You should see a text cursor appear (a vertical line) within the text field. This is where the data field will be placed.
Step #5 : Click into the text field again and type " to ". Again, make sure to provide a beginning space and ending space.
Step #6 : Now drag the Ending Date field directly onto the text field. Position it using your text curaor as a guide.
Step #7 : Resize the text field to assure that the whole string can be displayed properly.

The result : Your text field will now read "From 12/01/2008 to 12/31/2008". Combining text and data this way assures the spacing between "From" and "to" is always accurate.

2 comments:

Anonymous said...

How do you access Start Date and End Date (through sql?) I tried a formula start Date but this crashes (Date is a date field). You dont want to type in the dates if the source data comes in from another application via odbc

Justin Hill said...

"Start Date" and "End Date" are purely subjective in this context. They could be formulas or parameters. I was merely trying to explain how to easily combine data and text. There are no "native" Crystal Starting and Ending Dates.