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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Method 'ReportSource' of object 'ICrystalReportViewer9' failed 1

Status
Not open for further replies.

countdigit

Programmer
Nov 6, 2003
7
ID
hi guys, i'm new to crystal report. when i was still using crystal report (last week) 8.x this code WAS UP AND RUNNING, until i found out that i have to upgrade to 9.

1. already recreated by rpt's using version 9, including the ttx's

2. i uninstalled, restarted my computer, installed 9

3. check my vb project's references components and updated them to v9.

4. this fix from crystal decision: cr90devwin_en.zip
but i still keep on getting this message:

Method 'ReportSource' of object 'ICrystalReportViewer9' failed

... on this line:
frmPickSlipViewer.CRViewer91.ReportSource = CRXReport

and no report appears.

why?

if there are any good souls out there please help shed a light on this matter. any help would truly be appreciated. thanks in advance.

below are excerpts from my code...

' HERE ARE MY DECLARATIONS
Global gCon As ADODB.Connection 'global connection object
Global CRXApplication As New CRAXDRT.Application
Global CRXReport As New CRAXDRT.Report
Global CRXDatabase As CRAXDRT.Database
Global rs As New ADODB.Recordset
Global Report As New CrystalReport1

'HERE IS MY CODE
With rs
.Source = vsSQL
.ActiveConnection = gCon
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.Open
End With

curpath = CurDir()
If optPickSlip.Value = True Then
Set CRXReport = CRXApplication.OpenReport(curpath & "\GlobalPickList.rpt", 1)
Else
Set CRXReport = CRXApplication.OpenReport(curpath & "\GlobalSOList.rpt", 1)
End If

CRXReport.DiscardSavedData
Set CRXDatabase = CRXReport.Database
CRXDatabase.SetDataSource rs, 3, 1

frmPickSlipViewer.CRViewer91.Refresh

' THIS IS WHERE THE DREADED MESSAGE APPEARS (OK BEFORE I UPGRADED TO v9... PROMISE)
frmPickSlipViewer.CRViewer91.ReportSource = CRXReport

frmPickSlipViewer.Show 1


 
I was able to duplicate your error. It has to do with the sequence in which things are happening in your app.

1) Delete the following lines from the routine that builds the ado recordset and creates the report object:

frmPickSlipViewer.CRViewer91.Refresh
frmPickSlipViewer.CRViewer91.ReportSource = CRXReport

2) In their place, add the following line (do this after setting the datasource and before showing the viewer form):

CRXReport.ReadRecords

(Your ado dataset is global, so it shouldn't go out of scope, but this method eliminate any problems.)

3) In the on_load event of frmPickSlipViewer, add the following line just prior to the .ViewReport call:

CRViewer91.ReportSource = CRXReport

Hope that helps!
 
Thank you FVTrainer. I followed your instructions and it finally work!

Three cheers for FVTrainer... hep-hep! hurray! (x3)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top