Skip to Content
avatar image
Former Member

CRXI VBS Main + Subreport

hi

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

	'Scripting
	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)
	
	'Mainreport
	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")

    'Subreport 
    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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 07, 2011 at 09:34 PM

    What is the exact version of CR? (CR XI is not enough).

    Ludek

    Follow us on Twitter http://twitter.com/SAPCRNetSup

    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 07, 2011 at 07:41 PM

    moved to Legacy SDK forum

    Add comment
    10|10000 characters needed characters exceeded