I have a report containing 1 subreport :
subrep1.rpt. The subreport is linked to the
main report using 3 fields, namely fld1,
fld2 and fld3. I used ADO to bind the
records to the report during
runtime.However, only the main report is
printed correctly and the subreport only
have fld1, fld2, fld3 displayed and all the
other fields are empty. I then run
subrpt1.rpt as a main report on its own to
make sure that it is not my ADO that has
problem, and the report is correct. I have
been trying to solve this problem for a few
days without avail. Can anyone help please?
Thanks in advance.
The codes are as follow (CR9 and
VB.Net):
Dim rsBor As ADODB.Recordset
rsBor = New ADODB.Recordset
Dim cmd As ADODB.Command
cmd = New ADODB.Command
cmd.let_ActiveConnection(cnn)
With cmd
.CommandText = "Select fld1, fld2,
fld3, ...from Table1"
.CommandType =
ADODB.CommandTypeEnum.adCmdText
.CommandTimeout = 15
End With
End If
rsBor = cmd.Execute
Dim rsBor1 As ADODB.Recordset
rsBor1 = New ADODB.Recordset
Dim cmd1 As ADODB.Command
cmd1 = New ADODB.Command
cmd1.let_ActiveConnection(cnn)
With cmd1
.CommandText = "Select fld1, fld2,
fld3, ...from Table1 join Table2"
.CommandType =
ADODB.CommandTypeEnum.adCmdText
.CommandTimeout = 15
End With
End If
rsBor1 = cmd1.Execute
Dim PrintOne As New CRMainReport
PrintOne.SetDataSource(rsBor)
Dim crxSubreport1 As
CrystalDecisions.CrystalReports.Engine.Repor
tDocument
crxSubreport1 = PrintOne.OpenSubreport
("subrep1.rpt")
crxSubreport1.SetDataSource(rsBor1)
PrintOne.PrintToPrinter(1, False, 0, 0)