Subscript out of range error with SetDataSource
Posted on 2003-11-12
I'm using VB6 SP5 with Crystal 9 SP2. I'm trying to set my Data Source at runtime and keep getting an "Error 9, Subscript out of range". We've created a .dll that pulls the dataset information from the registry. We've defined this information and use the moRS recordset for many other functions in the program so we know it'll work. Even if I simplify things and define the recordset I continue to get the same "subscript out of range error". The code in my module is as follows:
Set Report = New CrystalReport2
Set moRS = New ADODB.Recordset
strSQL = "SELECT [tblPlant].[PlantID] "
strSQL = strSQL & "FROM tblPlant;"
If goDataConn.DataOpen Then
moRS.Open strSQL, goDataConn.Connection, adOpenForwardOnly, adLockReadOnly
lngTableCount = Report.Database.Tables.Count
CRViewer91.ReportSource = Report
For lngIndex = 1 To lngTableCount
'Report.Database.AddADOCommand goDataConn.Connection, rsCommand
Set moRS = Nothing