Solved

Visual Basic, Crystal Reports and RDC

Posted on 2001-07-02
1
339 Views
Last Modified: 2013-11-25
I need some help with a problem using RDC with Visual Basic.  My environment is Visual Basic 6.0 and Crystal Report 8.5.  I want to build a simple report that uses either unbound fields and/or formula fields.  then at runtime have the fields populated for a simple tabular column report to a SQL Server database. Most of the Examples Crystal Reports provide use an MDB file and are useless for client/server.  I have purposely kept this example simple.  I am trying to connect to a stored procedure with no parameters in it.

The designer builds the following code behind the form with the form with the Crystal Reports viewer on it to which I added the ADO code for connecting to SQL Server:

Dim Report As New CrystalReport1

Private Sub Form_Load()

Dim strCon As String
Dim adoTest As New ADODB.Connection
Dim adoCmd As New ADODB.Command

Screen.MousePointer = vbHourglass

strCon = "DSN=dsnTest; UID=userx; PWD=abcd;"
        With adoTest
            .ConnectionString = strCon
            .ConnectionTimeout = 60
            .Open
            .CursorLocation = adUseClient
        End With
       
        With adoCmd
            .CommandText = "usp_Test"
            .CommandType = adCmdTable
        End With

CRViewer1.ReportSource = Report
CRViewer1.ViewReport

Screen.MousePointer = vbDefault

End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth

End Sub


Now I am having a hard time knowing how to connect the dots and populate the report.  I have tried creating recordsets and looping through them to populate the report. I have tried inserting the loop into section shown below in the designer object.  The best I can do is get one record to display in the detail section.

Private Sub Section10_Format(ByVal pFormattingInfo As Object)

End Sub

Any help I can get to connect the dots and make this run would be greatly appreciated.

   
       
0
Comment
Question by:lbsaltzman
[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
1 Comment
 
LVL 12

Accepted Solution

by:
DRRYAN3 earned 200 total points
ID: 6245910
You must create a TTX (Data Definition) file and base your report design from it in Crystal Designer.  A TTX file is a tab delimited text file which specifies how your dataset will look.  A simple example might be:

OrderID<tab>long<tab>1
OAmount<tab>currency<tab>1.00
CustID<tab>long<tab>1
ODate<tab>date<tab>Jan 5, 2001
OMsg<tab>string<tab>20<tab>string sample value

Field 1 is the field name, 2 is the type, 3 is either the field size or a numeric example, and 4 is a string example.  You could use the Data Definition Tool in CRW, but notepad is much more efficient.

The Active Data driver is P2SMON.DLL

I haven't upgraded to 8.5, but in 8.0 using the Report Expert, you would select More Data Sources, Active Data, Active Data (Field Defs Only) and browse for your TTX file.

Design your report

At runtime, plug your ADO dataset into the RDC report by

dim crAppl as CRAXDRT.Application
dim crRep as CRAXDRT.Report
dim rs as ADODB.Recordset

' bunch of code to setup your recordset and load the data into it

set crAppl = new CRAXDRT.Application
set crRep = crAppl.OpenReport("C:\path\report.rpt")
' Set ADO recordset to first table in report
crRep.Database.Tables(1).SetDataSource rs, 3
' Be sure to insert a CR Smart Viewer on form and then
crViewer1.ReportSource = crRep
crViewer1.ViewReport

Let me know if you are using the CRPEAuto modules because the code is different.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

717 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