Click to See Complete Forum and Search --> : Report objects SetDataSource method


mjt
June 1st, 2005, 06:22 AM
Hi.

I'm using Crystal Reports 8.5, Visual Basic 6.0 (SP6) and ADO (MDAC 2.7)

I have a problem when trying to set a recordset for report's datasource more than once. There is a loop that goes through recordset's rows and in that loop recordset is set to report's datasource (with different filter-values, but this is not relevant, 'cause I tried also with totally different recordset). The problem is that report's data doesn't change, it always has the same data that was given in the first round of the loop. Database.Verify-method seems only to refresh recordset's field's properties, not the actual data..
Any ideas?

example:


public sub PrintReport(byref report as CRAXDRT.report)

dim rst as new ADODB.Recordset

rst.open "SELECT ..."

do until rst.EOF
if rst.field(foo) = VariableThatChangesInLoop then
rst.filter = "foo = " & VariableThatChangesInLoop
report.database.setdatasource rst
form1.viewer.reportsource = report
form1.viewer.viewreport
form1.show 1
rst.filter = ""
endif
rst.movenext
loop

end sub