Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with ADODB RecordSet & Crystal Viewer

Status
Not open for further replies.

billyhs

Programmer
Jul 28, 2004
11
ID
Dear Experts,

I'm having a problem with Crystal Report Viewer CRViewer1 not showing right amount of records speficied in my ADODB Recordset. The viewer instead is always displaying all records from my database.
I had proven using the VB6 debugger that the recordset recordcount contained right amount of records to display.
I'm using VB6, and Crystal Reports 7. Also had tried using the VS integrated Crystal Reports Designer to generate my report. But, the results are the same.

In the declaration section, I have these lines
Dim Report1 As New CrystalReport1
Dim rsProblemsReport As New ADODB.Recordset

And here is the code to display with the viewer after recordset had been filled,

Private Sub Form_Load()

Report1.Database.Tables(1).SetDataSource (rsProblemsReport)
CRViewer1.ReportSource = Report1
CRViewer1.ViewReport

End Sub

Could anyone tell me what could be wrong with my codes ?

Thanks very much for your help.

Billy.
 
Try adding these two lines around your call to SetDataSource:
[tt]
Report1.DiscardSavedData
Report1.Database.SetDataSource rsProblemsReport
Report1.ReadRecords
[/tt]
That should force a new read of the recordset. Did it ever work correctly, or has it always returned all records?

-dave
 
Thank you for your answer, Dave.
I don't have my development system right infront of me at this moment, but I will definitely try your suggestions once I am back at my office on Monday.
To answer your question, the CRViewer1 has always returned all records. It never worked correctly before.

Billy.
 
Hello Dave,

I have tried using the two lines you suggested, but Crystal Report is still showing all records.
Do I have to set anything in the report designer so that it will read from my recordset ?
Or any other suggestion that you might have ?

Thanks very much.

Billy.
 
Hello again Dave,

never mind my previous post. I have finally been able to show my report correctly by way of using the ttx file.

Thanks for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top