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,461 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
Comment Utility
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
Comment Utility
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
Comment Utility
Glad i could help

mlmcc
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 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

12 Experts available now in Live!

Get 1:1 Help Now