Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-07
3
Medium Priority
?
1,474 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 2000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 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…
Suggested Courses

610 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