Code examples using RDC to run a series of reports and save them to an excel fil
Posted on 2004-10-07
I am currently using the OCX control to run a report and save it an excel file. Here is the simplified version.
Private Sub form_load()
Dim rptname As String
Dim rptdest As String
Dim PARAM0 As String
Dim PARAM1 As String
Dim PARAM2 As String
rptname = "G:\APPS\GPP\SRS\Large Claim Analysis.rpt"
rptdest = "G:\Data\Group Profilling\Large Claim Analysis data.xls"
CrystalReport1.ReportFileName = rptname
CrystalReport1.Connect = "pwd=SA321"
CrystalReport1.ParameterFields(0) = "Beginning Month of Year;DATE(2003,10,01)Time(00,00,00,000);TRUE"
CrystalReport1.ParameterFields(1) = "Ending Month of Year;DATE(2003,10,01)Time(00,00,00,000);TRUE"
CrystalReport1.ParameterFields(2) = "HPcode;string(UNIC);true"
CrystalReport1.Destination = crptToWindow
CrystalReport1.PrintFileType = crptExcel50
CrystalReport1.PrintFileName = rptdest
CrystalReport1.Connect = "ODBC;UID=SA;PWD=SA321;DSN=EZCap RSDB;Database=WINRPT"
CrystalReport1.Action = 1
Do While CrystalReport1.Status <> 3
This code works well except when the report has a subreport I get the error 20599 cannot open SQL server. I believe that using the RDC I can get past this problem. However I have never used the RDC. I have access to the RDC but I am hoping that someone can help me with some coding examples that will do the same thing as above except using the RDC.