-
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
-
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.