Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

CRXI VBS Main + Subreport


Im using VBS to transfer Values to CRXI (Runtime Files) to make a PDF print out.

Only the Mainreport is not the problem. When i added a subreport in a Mainreport the subreport remains empty!

What is wrong with my VBS Code?

Dim Appn
Dim Report
Dim fso
Dim path
Dim Subreport

On Error Resume Next

	Set fso = CreateObject("Scripting.FileSystemObject")

	'Crystal Runtime 
	Set Appn = CreateObject("CrystalRuntime.Application")

	'Data name
	path = "productionreport_WFI_day" & "_" & Year(Now) & "_" & Month(Now) & "_" & Day(Now) & "_" & Hour(Now) & "_" & Minute(Now) & "_" & Second(Now)
	Set Report = Appn.OpenReport("Mainreport.rpt")

	'Parameters for mainreport
	Report.ParameterFields.GetItemByName("From").AddCurrentValue CDate("2011-06-06 00:00:00")
	Report.ParameterFields.GetItemByName("Till").AddCurrentValue CDate("2011-06-07 00:00:00")
	Report.ParameterFields.GetItemByName("test1").AddCurrentValue CDbl("1.00")
	Report.ParameterFields.GetItemByName("test2").AddCurrentValue CDbl("2.00")
	Report.ParameterFields.GetItemByName("test3").AddCurrentValue CDbl("3.00")

    Set Subreport = Appn.OpenSubreport("Timers") 'Timers = Name of supreport in the mainreport
	'Parameters for subreport
    Subreport.ParameterFields.GetItemByName("From").AddCurrentValue CDate("2011-06-06 00:00:00")
	Subreport.ParameterFields.GetItemByName("Till").AddCurrentValue CDate("2011-06-07 00:00:00")
	Subreport.ParameterFields.GetItemByName("test1").AddCurrentValue CDbl("1.00")
	Subreport.ParameterFields.GetItemByName("test2").AddCurrentValue CDbl("2.00")
	Subreport.ParameterFields.GetItemByName("test3").AddCurrentValue CDbl("3.00")

	Report.EnableParameterPrompting = False
	Report.ExportOptions.FormatType = 31 ' crEFTPortableDocFormat
	Report.ExportOptions.DestinationType = 1 ' crEDTDiskFile
	Report.ExportOptions.PDFExportAllPages = True
	Report.ExportOptions.DiskFileName = "C:\Report\" & path & ".pdf"
	Report.Export (False)
	Set fso = Nothing
	Set Appn = Nothing
	Set Report = Nothing

Former Member

Code looks correct.

More code is here;

Also, you may want to search the KBase; text box in top right corner of this web page.

Other than that, go to XI R2A

- Ludek

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question