Thursday 29 August 2013

Is it possible to preserve the default formula fields values in a crystal report?

Is it possible to preserve the default formula fields values in a crystal
report?

I have a crystal report in which I'm trying to dynamically insert an
image. I've managed to make it work on the report itself by adding the
path to the image in the graphic location property and when I preview the
report the picture displayed is the one I intended to display, not the one
I'm using as placeholder.
However, it doesn't seem to work in the application (I get the image I
used as placeholder instead of the one I set the graphic location to).
After exporting the report from the report viewer, I found out that when
the report is displayed, the formula fields used are wiped and the value
I've stored in the Graphic Location of the picture - which is the path to
the image I want to show dynamically - is blank.
In the code of my application, I'm setting the formula field I'm using as
the path of the image I want to display.
Here's the code:
Dim CrReport As New ReportDocument
CrReport = New myReport
CrReport.DataDefinition.FormulaFields.Item("picpath").Text =
"""C:\Picture.jpg"""
CrystalReportViewer1.RefreshReport()
CrReport.Refresh()
picpath is the formula field that holds the path to the picture.
I'm using Crystal Reports XI and Visual Studio 2008.
What I'd like to know is: is it possible to preserve the default values of
the formula fields so that they can be changed programmatically at
runtime?
For example: If the default value I set for a formula field is
"C:\Picture.jpg", when I run the report in the application without
changing this value, it will remain the same.

No comments:

Post a Comment