Solved

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

Posted on 2002-04-08
3
399 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
ID: 6925956
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
ID: 6928336
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
ID: 6932980
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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 …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

867 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

16 Experts available now in Live!

Get 1:1 Help Now