Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am insterting a new subreport into CR 8 - How can I name it 3

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
I needed to create a new summary subreport for a Crystal 8.0 report, so I saved a current subreport off as a stand alone report and modified it to do what I wanted it to. When I try to insert it as a new subreport into my report, everything works fine except it won't let me name it. It arbitrarily assigns it the same name as a subreport already existing in the report footer section and calls my new one Subreport Name - 01. Is there any way to avoid this or to rename a Subreport?

Thanks in advance for any help!
 
Not that I know of. Save the subreport as a different name PRIOR to inserting it.

You can always use the *save subreport as* and rename it.

Then delete the current subreport and insert the newly renamed version of it.

-k kai@informeddatadecisions.com
 
I tried that and it doesn't work. It just names it the same as the existing subreport with -01 appended to it. Thanks for responding.
 
Not aware of any way to do this in CR itself.

If you have VB, the subreport name is a property you can find and change.

My cViewReport viewer can show that information, and let you change it. You can even do that with the demo version. Then export your report as a rpt, and the new report has subreports renamed the way you want. Editor and Publisher of Crystal Clear
 
There is a new Crystal utility called the rpt Inspector that allows you to make changes to all sorts of previously hidden properties, like subreport names and section heights (numericaly). It also lets you do batch searches and batch updates for multiple reports. I have a link to the demo on my website's "links" page. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi

You can achieve this by right clicking your subreport and then go to Format Subreport option

After this go to 'SUB REPORT ' tab

You will find 2 options

On-Demand sub report caption
Sub - Report preview tab caption

Go to the formula editor of this and type in your report name in Quotes.


Cheers
Ganesh
 
Ganesh,

This doesn't actually rename the subreport. The name of the subreport is what appears on the design tab of the subreport. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
I am struggling to change the sub report name, I have tried in VB, have run rptinspector (which shows the sub report name as read only) and tried cViewReport to change the subreport name. Does anybody have a step by step idiots guide on how to change this.

Thanks.
 
What version of CR are you using?

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- TEK2(AT)kenhamady.com
 
Since this might prove useful to many people who aren't using CR 9, here is the code necessary to change the name of a subreport programmatically using the RDC (VB 6 and CR 8.5, but should work with 8 as well, and maybe CR 7). Start a blank VB project, add a reference to Crystal Reports (7/8/8.5) ActiveX Designer Run Time Library (craxdrt.dll), and drop a Command button on the form.

Here's the code:
Code:
[COLOR=green]'General Declarations[/color]
Dim crxApp As New CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report
Dim crxSection As CRAXDRT.Section
Dim crxSubRpt As CRAXDRT.Report
Dim crxSubRptObj As CRAXDRT.SubreportObject
Dim rptObj As Object

Private Sub Command1_Click()

[COLOR=green]'Open the report that contains the subreport to be renamed[/color]
Set crxRpt = crxApp.OpenReport(App.Path & "\test.rpt")
[COLOR=green]'Loop through the Report sections[/color]
For Each crxSection In crxRpt.Sections
    [COLOR=green]'Look through the ReportObjects in this section[/color]
    For Each rptObj In crxSection.ReportObjects
        [COLOR=green]'Is this a subreport?[/color]
        If rptObj.Kind = crSubreportObject Then
            Set crxSubRptObj = rptObj
            If crxSubRptObj.SubreportName = [b]"SubreportNameToChange"[/b] Then
                [b]crxSubRptObj.SubreportName = "NewSubreportName"[/b]
            End If
        End If
    Next
Next

[COLOR=green]'Save the report with a new name, just in case[/color]
crxRpt.SaveAs App.Path & "\Changed.rpt", cr80FileFormat

[COLOR=green]'Cleanup[/color]
Set rptObj = Nothing
Set crxSubRptObj = Nothing
Set crxSubRpt = Nothing
Set crxSection = Nothing
Set crxRpt = Nothing
Set crxApp = Nothing

End Sub
Hope that helps you out.

-dave
 
Thanks Dave, thats fantastic, I tried it and it worked first time. Brilliant!!
 
rptInspector will not let you modify the subreport name for 8.5 reports.
You can not change the Report Path or Report File Name of a Sub-Report via .rpt Inspector because it's not exposed as a Read/Write property. You can change other properties of the sub-report including the Title.
 
chelseatech

My cViewReport viewer can show that information, and let you change it. You can even do that with the demo version. Then export your report as a rpt, and the new report has subreports renamed the way you want.


I tried that, but I can't fingure out how to do it. Can you give a little help please?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top