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,469 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

696 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