views:

96

answers:

4

I have some contract text that may change.

It is currently (non live system) stored in a database field (we determine which contract text to get by using other fields in table). I, however need to display a specific date (based on individual contract) within this text.

IE (but Jan 12, changes depending on the individual contract):

blah blah blah... on Jan 12, 2009... blah blah blah

but everything else in the contract text is the same.

I'm looking for a way to inject the date into this text. Similar to .NET's

Console.Write("Some text here {0} and some more here", "My text to inject");

Is there something like this? Or am I going to need to split the text into two fields and just concatenate?

I am always displaying this information using Crystal Reports so if I can inject the data in through Crystal then that's fine.

I am using Crystal Reports, SqlServer 2005 and VB.net

Thanks,

+1  A: 

Have you tried putting a text marker like the {0} above that can be replaced in the crystal reports code?

gunShu
+1  A: 

You could use some "reserved string" (such as the "{0}") as part of the contract, and then perform a replace after reading from the database.

If there's no option for this reserved string (for instance, if the contract may contain any type of string characters in any sequence, which I find unlikely), then you'll probably need to split into 2 text fields

Samuel Carrijo
+1  A: 

You can create a formula field and concatenate your text there.

If the data is stored in the database, the formula text should look like this: "Some static text " & totext({yourRecord.yourDateField}, "yyyy")

Or you can provide it as a parameter before you show the report:

    Dim parameterValue As New CrystalDecisions.Shared.ParameterDiscreteValue
    value.Value = yourDate
    Dim parameter As New CrystalDecisions.Shared.ParameterField
    parameter.ParameterFieldName = "MyParam"
    parameter.CurrentValues.Add(value)
    parameter.HasCurrentValue = True
    Me.CrystalReportViewer1.ReportSource = rapport
    Me.CrystalReportViewer1.ParameterFieldInfo.Clear()
    Me.CrystalReportViewer1.ParameterFieldInfo.Add(parameter)

Then the formula text should look like this:

"some static text " & {?MyParam}

Sebastien Desilets
A: 

I'm assuming you have a data source connected to your report. You can drag the field from the Database Explorer drop where it should appear. This way whenever the report runs the correct text will always be shown.

Brownman98