|
-
Mar 16th, 2002, 11:19 AM
#1
Thread Starter
Addicted Member
Crystal Report help please
Hi, i'm using Crystal Report 8.5 and i'm using unbound fields for the data in the report.
All i want is to know how to use for that report, a Recordset i create myself and not a recordset from a table or Connection.
I tried m_Report.Database.AddOLEDBSource and
m_Report.Database.SetDataSource m_RS
but it's giving errors
Any ideas ?
-
Mar 16th, 2002, 01:23 PM
#2
Thread Starter
Addicted Member
-
Mar 16th, 2002, 01:28 PM
#3
Addicted Member
I pity you I have no idea what your talking about but I pity you
-
Mar 17th, 2002, 11:54 PM
#4
Frenzied Member
I realize this is not exactly what you were looking for,
but it is an alternative approach. The report is designed in
the Crystal Reports RDC and is created using a
Data Definition File (a tab-delimited text file which describes
the data and datatypes used in the report). It makes use of the
Crystal Data Object (CDO) which simulates an ADO recordset.
At runtime a virtual recordset (CDO) which matches the Data
Definition File is created and populated using an array, and then
applied to the report. It stores no data with the report.
This example creates a report comprised of only 1 record.
This could be looped to run through all desired records,
or the array could be two-dimensional allowing for multiple
records. This example assumes the report created in the RDC
is named 'crTest'
Project References:
Crystal Reports 8.5 ActiveX Design and Runtime Library
Crystal Reports 8.5 ActiveX Designer Run Time Library
Declarations:
VB Code:
'declare report objects
Public rptTest As New crTest
'declare virtual recordset object
Public cdoTest As Object
'declare variables/arrays
Public arrayRpt() as Variant
To create the report, call CreateReport
VB Code:
Public Sub CreateReport()
'declare components
Dim rptDB As CRAXDRT.Database
'create the virtual recordset
CreateReportSet
PopulateReportSet
'apply virtual recordset to report
Set rptDB = rptTest.Database
rptDB.SetDataSource cdoTest, 3, 1 '3 and 1 are the only values currently supported
End Sub
Private Sub CreateReportSet()
'create virtual recordset
Set cdoTest = CreateObject("CrystalDataObject.CrystalComObject")
'add fields to virtual recordset
With cdoTest
.AddField "Field1", vbString
.AddField "Field2", vbString
.AddField "Field3", vbString
End With
End Sub
Private Sub PopulateReportSet()
'init
ReDim arrayRpt(2) As Variant 'redim to handle all fields in the virtual recordset
'connect to the data source and retrieve record, alternatively the report could be created
'entirely or partially from user input with the input made part of the virtual recordset
arrayRpt(0) = 'a value from the data source, or textbox, combobox, listbox, etc
arrayRpt(1) = 'a value from the data source, or textbox, combobox, listbox, etc
arrayRpt(2) = 'a value from the data source, or textbox, combobox, listbox, etc
'add array to virtual recordset
cdoTest.AddRows arrayRpt
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|