Results 1 to 4 of 4

Thread: Crystal Report help please

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    Anywhere
    Posts
    136

    Red face 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 ?

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    Anywhere
    Posts
    136

    any help ?

    Any help please ?

  3. #3
    Addicted Member
    Join Date
    Mar 2002
    Posts
    225
    I pity you I have no idea what your talking about but I pity you

  4. #4
    Frenzied Member John McKernan's Avatar
    Join Date
    Jan 2002
    Location
    SE PA
    Posts
    1,295
    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:
    1. 'declare report objects
    2.     Public rptTest As New crTest
    3.    
    4. 'declare virtual recordset object
    5.     Public cdoTest As Object
    6.  
    7. 'declare variables/arrays
    8.     Public arrayRpt() as Variant
    To create the report, call CreateReport
    VB Code:
    1. Public Sub CreateReport()
    2.     'declare components
    3.     Dim rptDB As CRAXDRT.Database
    4.  
    5.     'create the virtual recordset
    6.     CreateReportSet
    7.     PopulateReportSet
    8.  
    9.     'apply virtual recordset to report
    10.     Set rptDB = rptTest.Database
    11.     rptDB.SetDataSource cdoTest, 3, 1   '3 and 1 are the only values currently supported
    12. End Sub
    13.  
    14. Private Sub CreateReportSet()
    15.     'create virtual recordset
    16.     Set cdoTest = CreateObject("CrystalDataObject.CrystalComObject")
    17.    
    18.     'add fields to virtual recordset
    19.     With cdoTest
    20.         .AddField "Field1", vbString
    21.         .AddField "Field2", vbString
    22.         .AddField "Field3", vbString
    23.     End With
    24. End Sub
    25.  
    26. Private Sub PopulateReportSet()
    27.     'init
    28.     ReDim arrayRpt(2) As Variant    'redim to handle all fields in the virtual recordset
    29.    
    30.     'connect to the data source and retrieve record, alternatively the report could be created
    31.     'entirely or partially from user input with the input made part of the virtual recordset
    32.  
    33.     arrayRpt(0) = 'a value from the data source, or textbox, combobox, listbox, etc
    34.     arrayRpt(1) = 'a value from the data source, or textbox, combobox, listbox, etc
    35.     arrayRpt(2) = 'a value from the data source, or textbox, combobox, listbox, etc
    36.  
    37.     'add array to virtual recordset
    38.     cdoTest.AddRows arrayRpt
    39. 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
  •  



Click Here to Expand Forum to Full Width