0

I am getting this error when I try to pass an sql string to an external crystal report. extenal in the the report is not part of the project but a crystal report file. I have uploaded a summarised version of the project

Dim Report As New CrystalReport1

Set rs = New ADODB.Recordset
Dim strSql As String

Dim ReportStartDate As Date
Dim ReportEndDate As Date

ReportStartDate = txtStartDate.Text
ReportEndDate = txtEndDate.Text

strSql = "SELECT * from Outwards WHERE date >= #" & ReportStartDate & "#  And date <= #" & ReportEndDate & "# and ShiftNumber >= " & txtStartShift.Text & " And ShiftNumber <= " & txtEndShift.Text & ""
'rs.Open strSql, Con
rs.Open strSql, Con, adOpenKeyset, adLockOptimistic, adCmdText


Report.DiscardSavedData
Report.Database.Tables(1).SetDataSource rs, 3'>>> Where the error shows up

CRViewer1.ReportSource = Report.Application.OpenReport("C:\CrystalSample\NOPS36.rpt")

CRViewer1.Refresh
CRViewer1.ViewReport

Set Report = Nothing
Set rs = Nothing
3
Contributors
3
Replies
19
Views
4 Years
Discussion Span
Last Post by imBaCodes
0

okay, so I was searching around and I found that this Click Here guy was working on the same scenario that I was working on and probably got the solution but he didnt post it, any help would be appreciated

0

Report.Database.Tables(1).SetDataSource rs, 3'>>> Where the error shows up

If "1" (the only subscript there) is out of range, are sure that that should not be:

`Report.Database.Tables(0).SetDataSource rs, 3

1

Tables(1)

The error show up because he cant find table(1) check you data. TnTinMN, maybe is right.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.