|
-
Dec 8th, 2003, 02:02 PM
#1
Thread Starter
Lively Member
*Resolved* Change file path of subreport at runtime
Hi! Does anyone have or know of any sample code that can change the file path of a sub report at runtime?
Basically I have one blank Crystal Report which contains a number of subreports. I want the user to have the ability to change the order in which the reports are printed so I want to be able to assign the file path of the subreport at runtime. Is this even possible?
Thanks in advance to anyone who can help.
-Scott
Last edited by slaws; Dec 8th, 2003 at 05:11 PM.
Scott
-
Dec 8th, 2003, 05:03 PM
#2
I don't know of any way to change the path of an existing subreport but you might be able to get want you want by using the AddSubReportObject or ImportSubReport methods of the Section object. I think these methods may depend on your version and/or license. Sorry, no sample code - never tried them.
-
Dec 8th, 2003, 05:11 PM
#3
Thread Starter
Lively Member
I tried it and it worked. Thanks a lot. For anyone who would like the code here it is:
VB Code:
Dim crSection As CRAXDRT.Section
Dim crSections As CRAXDRT.Sections
Dim crObject As Object
Dim crSubReport As CRAXDRT.SubreportObject
Dim sName As String
Dim sqlReports
Dim rsReports As New ADODB.Recordset
Dim strFootIndex As String
If db.State = adStateClosed Then db.Open strMConnect
Set CReport = CApp.OpenReport(App.Path & "\SalarySurvey.rpt", 1)
sqlReports = "SELECT Reports.RPT_ID, Reports.Report, Reports.PrintSeq, Reports.Print, Reports.ReportFile From Reports Where (((Reports.Print) = -1)) ORDER BY Reports.PrintSeq;"
If rsReports.State = adStateOpen Then rsReports.Close
Set rsReports = Nothing
rsReports.Open sqlReports, db, adOpenStatic, adLockOptimistic
If rsReports.RecordCount > 0 Then
rsReports.MoveFirst
'Set crSection = CReport.Sections.Item("RFa")
Do While Not rsReports.EOF
strFootIndex = Chr(96 + rsReports("PrintSeq"))
Set crSections = CReport.Areas("RF").Sections
crSections.Add "RF" & srtFootIndex
Set crSection = CReport.Sections.Item("RF" & strFootIndex)
Set crSubReport = crSection.ImportSubreport(App.Path & "\" & rsReports("ReportFile"), 0, 250)
With crSubReport
.LeftLineStyle = crLSNoLine
.RightLineStyle = crLSNoLine
.TopLineStyle = crLSNoLine
.BottomLineStyle = crLSNoLine
End With
rsReports.MoveNext
Loop
End If
frmLabels.CRLabel.Visible = True
frmLabels.CRLabel.ReportSource = CReport
frmLabels.CRLabel.ViewReport
frmLabels.CRLabel.Zoom 75
frmLabels.Show
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|