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!

Saved subreport cannot be renamed? 2

Status
Not open for further replies.

eo

MIS
Apr 3, 2003
809
Hi

Created a sub report within the primary report. Wanted to created a mirror of the subreport (with slight changes) so I right clicked on the subreport in the primary report, and selected 'save subreport as'. I saved the sub report as an independant report and give it a unique name. I made my slight changes to it and inserted the new report as another subreport into the primary report. The name I chose is now not used for the newly inserted subreport, in stead the application autmoatically uses a version of the original subreport name. Why does this happen, and more importantly...
How can I rename this subreport more approrpiarely?

Many thanks,
EO

Etienne Oosthuysen
Hertfordshire, England
 
Once a report has been inserted, it's subreport object name is hard coded. Know one knows why. You can change this very easily in v9, but not in older versions. That is why I always keep the subreport separate and rename each instance before I insert it. Once inserted it is locked.

If you are a programmer I believe you have access to this name property in VB, using the RDC, or I believe that you can also change this using a tool called rptInspector, which uses the RDC. There is a link to the rptInspector on my web site LINKS page.

Before I learned about the RDC I did once successfully hex-edit the characters within the RPT file, but that is very time consuming and can potentially muck up the file. I think there is even an old post here in TT where I described this technique.

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
- tek@kenhamady.com
 
Report Design Component - used to integrate into VB apps.

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
 
Report Designer Component - one of the methods for integrating Crystal w/the programming language of your choice.

-dave
 
ah.

thank you.
(i was never using that name so i was confused at first)
 
ok. it is me again. :(

has anyone done it lately?
(i can not find right method to do it. neither if i use the report with the subreport or the extacted subreport)
 
This works for CR9. Don't have 8/8.5 to test:
Code:
Dim crxApp As New CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report
Dim subReport As CRAXDRT.SubreportObject
Dim rptObject As Object
Dim sect As CRAXDRT.Section
Dim strPath As String

strPath = "C:\Rail_Pickup_Order.rpt"

Set crxRpt = crxApp.OpenReport(strPath)

'Loop through the main report's sections to find the subreports
For Each sect In rpt.Sections
    For Each rptObject In sect.ReportObjects
        If rptObject.Kind = crSubreportObject Then
            Set subReport = rptObject
            'Change the 'Shippers' subreport to 'AllShippers'
            If subReport.SubreportName = "Shippers" Then
                subReport.SubreportName = "AllShippers"
            End If
            Set subReport = Nothing
        End If
    Next
Next

'Save the report
rpt.SaveAs Replace(strPath, ".", "_1."), crDefaultFileFormat

Set sect = Nothing
Set crxApp = Nothing
Set crxRpt = Nothing
-dave
 
Vidru,
Great solution. Only glitch is that you have used "rpt" instead of "crxRpt". That is minor. You saved my day
Philipose
 
Ahhh... oh well, can't edit it, so hopefully anyone who decides to use it will catch it on their own, or scroll down to your post.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top