Results 1 to 3 of 3

Thread: VB6.0 and CR 8.0 problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    8

    VB6.0 and CR 8.0 problem

    I am using VB6.0 , Access 2000,abd CR 8.0.
    I am using the following code.


    'Add reference to Crystal Reports x.x ActiveX Designer RunTime Library
    'Add component Crystal Reports Viewer Control
    'Add reference to Microsoft ActiveX Data Objects 2.8 Library
    'oCnn = current open ADO connection object
    Private Sub Command1_Click()

    Dim oApp As CRAXDRT.Application
    Dim oReport As CRAXDRT.Report
    Dim oRs As ADODB.Recordset
    Dim sSQL As String

    sSQL = "SELECT * FROM Table1"
    Set oRs = New ADODB.Recordset
    Set oRs = oCnn.Execute(sSQL)
    Set oApp = New CRAXDRT.Application
    Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt", 1)
    (1) oReport.Database.SetDataSource oRs, 3, 1
    crvMyCRViewer.ReportSource = oReport
    crvMyCRViewer.ViewReport

    End Sub
    I had two queries:-
    (a) I am getting an error report on line marked (1) that " Subscript beyond Range". I am not able to find a solution. when "MyReport.rpt" is already connected to a database and is configured, I am getting a report, but when a new blank report is used in its palce, I am not getting any result. Can anyone please tell me how to proceed ?


    (2) If the report is automatically placed in the form by the VB, can I get a report? If so, can anyone give me a sample code?

    thanks in advance,
    GeoNav

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: VB6.0 and CR 8.0 problem

    but when a new blank report is used in its palce, I am not getting any result
    Crystal does not magically generate a report based on a recordset. You still need to add the fields to the report file.

    Since you are using recordsets as your datasource you don't need to login to a database. From the Add Database screen, choose the More Data Sources -> Active Data -> Active Data (Field Definitions Only) and setup the information.

    See the topic Data Definition Files in the developer help file for more information.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    8

    Re: VB6.0 and CR 8.0 problem

    Hello brucevde,

    Thanks for the reply.
    Can you help me in the first part of the question?
    Thanks
    GeoNav

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