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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Naming subreports

Status
Not open for further replies.

peterswan

Programmer
Sep 25, 2002
263
US
Hello,

I'm bringing a lot of subreports into one main report. In doing so I copied a lot of the existing subreports into a folder, renamed them, and brought them into the main report and altered them. Everything worked fine until the names of the subreports, as listed in the main report, never saw the new names that I had named them. The new names were the same as the old names, except with an -01 or and -02 attached at the end of the names. So now my reports don't have good names assigned to them where I can see what I'm opening.

Is there any way to rename a subreport and have that name show up in the main report?

Thanks for any help,

Peter Swanson [smile]
 
This is a known problem. Once a report has been a subreport it is permanently branded with a subreport name. You have to rename the original, and insert it BEFORE it has been a subreport.

One solution, is to download the demo of rptInspector (see my web site). This tool gives you access to the subreport name property. CRv9 allows this directly in Crystal Reports.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
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.
 
Which Crystal? You can change names in Crystal 10, by right-clicking, choosing [Format Subreport] and changing the name from the [Subreport] tab.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
If you have dot net, here's some code that will allow you to rename the subreport. You point to the original subreport file, it will import it to a new report and change the name. You can then open the new report and export with the new name.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim cr As New CRAXDDRT.Application
Dim rpt As CRAXDDRT.Report
Dim r2 As CRAXDDRT.Report
Dim sec As CRAXDDRT.Section
Dim sbr As CRAXDDRT.SubreportObject
Dim sFile As String
Dim sF1 As String
Dim sF2 As String
Dim sPath As String
Dim sTRGPath As String
Dim newName As String

sTRGPath = "C:\reports\"

sPath = "C:\dev source\gideons\reports\"

Me.OpenFileDialog1.Filter = "CRX|CNI*.rpt"
Me.OpenFileDialog1.InitialDirectory = sPath
Me.OpenFileDialog1.ShowDialog()
sF1 = Me.OpenFileDialog1.FileName
sF2 = sTRGPath & sF1.Substring(30)
newName = Me.OpenFileDialog1.FileName
newName = newName.Substring(42)
newName = newName.Substring(0, newName.Length - 4)
rpt = cr.NewReport()
rpt.PaperOrientation = CRAXDDRT.CRPaperOrientation.crLandscape

sbr = rpt.Sections(2).ImportSubreport(sF1, 0, 0)

sbr.SubreportName = newName
If Dir(sF2) <> "" Then Kill(sF2)
rpt.SaveAs(sF2, CRAXDDRT.CRReportFileFormat.cr80FileFormat)

MsgBox(sbr.SubreportName.ToString() & " " & sF2)

sbr = Nothing
sec = Nothing
rpt = Nothing
cr = Nothing



End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top