Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2002-04-08
3
407 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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 …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

807 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