Solved

Code examples using RDC to run a series of reports and save them to an excel fil

Posted on 2004-10-07
3
1,463 Views
Last Modified: 2013-12-26
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
    'crptToFile
    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
    Loop



End Sub

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.



0
Comment
Question by:jaredodell
  • 2
3 Comments
 
LVL 5

Expert Comment

by:Z03niE
ID: 12256900
In this link you may find a code to export Crystal Report to PDF.You may change the code so that it will export to Excel.

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21074843.html

To do so change the following line :

CrxReport.ExportOptions.FormatType = crEFTPortableDocFormat   'declaring the export type, in this case pdf
To :
CrxReport.ExportOptions.FormatType = crEFTExcel97   'Export to Excell 97 format.

And about the connection parameter, the line is as :

CrxReport.ParameterFields.GetItemByName("@param").AddCurrentValue Trim(txtparam.Text)  'inserting current value to the report parameter
CrxReport.Database.LogOnServer "pdsodbc.dll", "DSN Name", "Database Name", "Username","password" 'The connection Line Code
        CRViewer91.ReportSource = CrxReport  'CRViewer91 is the object viewer name,this line declare crxreport as the report object to be viewed


Hope that help.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 12258583
Here is an excellent paper on converting from the OCX to the RDC

http://support.businessobjects.com/communityCS/TechnicalPapers/scr8-ocxtordc.pdf.asp

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 12439824
Glad i could help

mlmcc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now