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,471 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 101

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 101

Expert Comment

by:mlmcc
ID: 12439824
Glad i could help

mlmcc
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

688 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