Results 1 to 2 of 2

Thread: Crystal report trying to connect to database query!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253

    Exclamation

    I'm trying to connect a new crystal report to a query in my database. I get an error when I try to add the query to the new report:

    Error opening file
    There are no fields in the file "qry:TotalTime"

    I'm using MS Access 97 with the ado connection and OLEDB in the connection string. I have fields in this query from 2 tables in the same database, so I'm not sure why I get this error. Can anyone help?

    Thanks aja

  2. #2
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    Here's an example of how I get an ado recordset into a crystal report. The report is created using report designer component for VB. I have another form (frmReport) that contains the crystal report viewer control (crvCommon).

    Code:
    Private Sub mnuInitialReportsDue_Click()
        Dim strSql As String
        Dim rstTemp As ADODB.Recordset
        Dim strReportDate As String
        Dim rptCurrent As rptInitialReportDue
        
        strReportDate = Now
            
        strSql = "SELECT Referral.DateFaxed, Referral.FileNum, Referral.ClientNum, Referral.StaffID "
        strSql = strSql & "From Referral "
        strSql = strSql & "Where (((Referral.DateFaxed) > #" & Format(DateAdd("d", -45, strReportDate), "MM/dd/yyyy") & "#)) AND (((Referral.DateFaxed) < #" & Format(DateAdd("d", -38, strReportDate), "MM/dd/yyyy") & "#)) "
        strSql = strSql & "ORDER BY Referral.DateFaxed, Referral.FileNum;"
        
        Set rstTemp = New ADODB.Recordset
        rstTemp.Open strSql, fCnn1
        
        Load frmReport
        Set rptCurrent = New rptInitialReportDue
        rptCurrent.Database.SetDataSource rstTemp
        rptCurrent.ReadRecords
        rptCurrent.ReportTitle = "WSIB Initial Reports Due"
        frmReport.crvCommon.ReportSource = rptCurrent
        frmReport.crvCommon.ViewReport
        frmReport.crvCommon.Visible = True
        frmReport.Show
        
        rstTemp.Close
        Set rstTemp = Nothing
        
    End Sub
    Hope this helps.

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