Results 1 to 5 of 5

Thread: Having trouble loading recordset into crystal report.

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    Having trouble loading recordset into crystal report.

    Hello all,

    I have created a crystal report (in crystal report 10), but cannot get the info from the form to load into it.

    I am using code that I got on here from doing searches.

    vb Code:
    1. Case "Print"
    2.             Dim SQL As String
    3.             Dim oApp As New CRAXDDRT.Application
    4.             Dim oReport As New CRAXDDRT.Report
    5.  
    6.             Set oReport = oApp.OpenReport(App.Path & "\ECI.rpt,1")
    7.             oReport.Database.Tables(1).Location = App.Path & "\ECI.mdb"
    8.  
    9.  
    10.             SQL = "SELECT tblECI.fldFDID,tblECI.fldDOB,tblECI.fldFname,tblECI.fldMI,tblECI.fldLname,tblECI.fldAddress," & _
    11.             " tblECI.fldCity,tblECI.fldState,tblECI.fldZip,tblECI.fldSname,tblECI.fldChildren1,tblECI.fldDob1,tblECI.fldChild2,tblECI.fld" & _
    12.             " tblECI.fldDob2,tblECI.fldChild3,tblECI.fldDob3,tblECI.fldChild4,tblECI.fldDob4,tblECI.fldChild5,tblECI.fldDob5," & _
    13.             " tblECI.fldChild6,tblECI.fldDob6,tblECI.fldChild7,tblECI.fldDob7,tblECI.fldContact1,tblECI.fldRelationship1," & _
    14.             " tblECI.fldAddress1,tblECI.fldPhone1,tblECI.fldCell1,tblECI.fldOther1,tblECI.fldContact2,tblECI.fldRelationship2," & _
    15.             " tblECI.fldAddress2,tblECI.fldPhone2,tblECI.fldCell2,tblECI.fldOther2,tblECI.fldContact3,tblECI.fldRelationship3," & _
    16.             " tblECI.fldAddress3,tblECI.fldPhone3,tblECI.fldCell3,tblECI.fldOther3,tblECI.fldPrimary,tblECI.fldFDID1,tblECI.fldSecondary," & _
    17.             " tblECI.fldFDID2,tblECI.fldReligious,tblECI.fldSrequest,tblECI.fldComments FROM " & _
    18.             " tblECI " & _
    19.             "WHERE tblECI.fldFDID =  '" & txtFDID.Text & "'"
    20.            
    21.      
    22.             Set rs = DBconnection.Execute(SQL)
    23.  
    24.             With oReport
    25.                 .Database.SetDataSource rs, , 1
    26.                 .PaperOrientation = 1
    27.                 .PaperSize = 2
    28.                 .EnableParameterPrompting = False
    29.                 .DiscardSavedData
    30.             End With
    31.        
    32.            
    33.             crvMyCRViewer.ReportSource = oReport
    34.             crvMyCRViewer.ViewReport

    I keep getting an error message that states:
    " Variable not defined" and points to the crvMyCRViewer, but I'm not sure what to define the viewer as.

    Any help would be greatly appreciated.


    Now that I think of it; maybe I'm going about this the wrong way.
    What I have is a form which the user does a search and this returns a recordset which loads into the form.
    Then when the user clicks on the print button I want the information to load into the crystal report that I created.

    Am I headed in the right direction?
    Last edited by cfd33; Oct 8th, 2007 at 07:19 PM.

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