Solved

Is there any way to change the report title at runtime?

Posted on 2002-04-08
3
396 Views
Last Modified: 2008-02-01
Like the title say...
Thanks in advance
0
Comment
Question by:CaptainKirk
3 Comments
 
LVL 1

Accepted Solution

by:
AConover earned 100 total points
Comment Utility
Scenario 1:

You could make the title a parameter field that the user would have to fill in when the report is run:
1.  In Field Explorer create a new parameter field.
2.  Give it a name, prompting text and select string for value type.
3.  Place this field in the page header or report header (where ever you want the title to display).
4.  You can modify like any other field for fonts, etc.

Now when the report is run, the user will be prompted to type in a title.

Scenario 2:

If you only wanted a choice of specific titles to choose from.  Create the parameter field like above except in options click on the default values button and add values for the user to select from (ex. a b and c).  This will create a drop down box for user. Then create a formula for choices like below:

if {parameter field you created} = "a" then "Report title one" else
if {parameter field you created} = "b" then "Report title two" else
if {parameter field you created} = "c" then "Report title three"

Now put this formula where you want your title to be.  When the user runs the report, the parameter field will prompt them to select a, b or c and the formula will display the correct title.

Hope this helps.

AC

0
 
LVL 6

Expert Comment

by:dbirdman
Comment Utility
Here's an example to add the title at runtime with code.  you can do this after the user selects the title, or set the title without user intervention.  This requires that a Parameter Field is set up in the Crystal Report, as AConover Stated.  This particular code is untested, though should work:

Dim crApp As CRAXDRT.Application
Dim crRpt As CRAXDRT.Report
Dim crSection As CRAXDRT.Section
Dim ImgObject As OLEObject
Dim strRptName As String
Dim strImgName As String
Dim Params As CRAXDRT.ParameterFields
Dim HeaderParam As CRAXDRT.ParamFieldDefinition

Set crApp = New CRAXDRT.Application

strRptName = "C:\MyReport.rpt"

'Open Report
If IsObject(crRpt) Then
    Set crRpt = Nothing
End If

Set crRpt = crApp.OpenReport(strRptName, 1)

set Params = oRpt.Parameterfields
set HeaderParam = Params.Item(1)
         
'Parameter 12 in SetCurrentValue tags parameter as a String
Call HeaderParam.SetCurrentValue (CStr(HeaderText), 12)

crRpt.MorePrintEngineErrorMessages = False
crRpt.EnableParameterPrompting = False
crRpt.DiscardSavedData

' Set the viewer's report source to the Report object
CRViewer1.ReportSource = crRpt
CRViewer1.ViewReport


Hope this helps.
0
 
LVL 1

Expert Comment

by:Garfy
Comment Utility
why use all the parameters.....  in VB, the Crystal Report control has a property, Report Title.  If you have placed the report title on your report and want to change it at runtime, just use the following syntax

MyCrystalReportControl.ReportTitle = "My Title"

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now