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

Automate refreshing of Reports with subreports

Status
Not open for further replies.

williey

Technical User
Jan 21, 2004
242
I have some reports with subreport embedded in them. Using VB scripts to refresh them gets a little tricky.

I found some document on CR website. The refresh runs without error but no data is refreshed..

Here is a sample of my script.

Code:
' Declare variables
Dim oRptApp, oRpt, oRptParam1
Dim oSubReport1, oSubReport2
Dim oRptParam2, oRptParam3
Dim rptcnt

' Set the object for the App
Set oRptApp = CreateObject("CrystalRuntime.Application")


'For rptcnt = 1 to NUM_OF_REPORTS
For rptcnt = 1 to 1
 
  Set oRpt = oRptApp.OpenReport(INPUT_PATH & IN_FILE(rptcnt), 1)

  Set oSubreport1 = oRpt.OpenSubreport("Subreport1")

  Set oSubreport2 = oRpt.OpenSubreport("Subreport2")

  ' Set the first parameter
  Set oRptParam1 = oRpt.ParameterFields.Item(1)

  Set oRptParam2 = oSubReport1.ParameterFields.Item(1)

  Set oRptParam3 = oSubReport2.ParameterFields.Item(1)

  ' Clear the first parameter value
  oRptParam1.ClearCurrentValueAndRange
  oRptParam2.ClearCurrentValueAndRange
  oRptParam3.ClearCurrentValueAndRange
msgbox(endDate)
  ' Set the value of the first param
  oRptParam1.AddCurrentValue CDate(endDate)
  oRptParam2.AddCurrentValue CDate(endDate)
  oRptParam3.AddCurrentValue CDate(endDate)

  oRpt.ReadRecords

  ' Write to file to disk
  oRpt.SaveAs Destdir & "\" & OUT_FILE(rptcnt) & "_" & "D" & strDate & FILE_EXT , 2048

Next

------------------------------------------
There are 10 kinds of people in this world. One that understands binary and the other one that does not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top