Solved

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

Posted on 2002-04-08
3
414 Views
Last Modified: 2008-02-01
Like the title say...
Thanks in advance
0
Comment
Question by:CaptainKirk
[X]
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
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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