[Last Call] Learn how to a build a cloud-first strategyRegister Now


How to change the reportsource on a CRViewer control

Posted on 2006-05-17
Medium Priority
Last Modified: 2008-02-01
Hi all,

I have a CRViewer control on a form which also has a tree control.
The tree control lists the titles of the reports the user may want to see in the viewer.
When the user clicks on the tree the first time, the report is displayed fine, using the code below.

When the user again clicks on the tree (2nd and subsequent times), all that is shown is a white background.
Also, after a few clicks, errors start appearing.

It seems that the viewer is unable to refresh its reportsource properly.
Here is a (condensed) snippet of the existing code

    rfn = {The filename of the report to load}
    Set rpt = crxApp.OpenReport(App.Path & "\Reports\" & rfn)
    rpt.Database.LogOnServer "p2sodbc.dll", "Webserver", "webserver", "username", "password"
    With frmReports.crv
       .ReportSource = rpt
    End With

Any suggestions as to how to make this work consistently?
Question by:ajmac-b
  • 2
  • 2

Expert Comment

ID: 16705409
What versions are you using for CR, your App (appears to be VB) and what tree control are you using?  Also, is this a web app (assuming) or Windows?

Author Comment

ID: 16705420
Thanks for you reply
CR V 8.5
Not a web app and using the TList control from BennetTec software

The only way I have been able to do this is to unload and load the form, to force the CRViewer control to be instantiated each time. This is fine when no other form is visible, but ugly when there are, as the other form flashes on while the unload/load cycle takes place.

I'm wondering, I guess, how to initialise the CRViewer control each time.

Accepted Solution

janmarini earned 150 total points
ID: 16705486
Sorry, I am not familiar with that 3rd party tree control - so I have no idea how it works.  Also, I have not used VB 6 and CR 8.5 in many years so I can't assist you immediately.  However, I think the main thing you need to do is to test that you are able to grab the 'rfn' and that it 'refreshes' before you set the rpt (your 2nd line of code) ...  What happens when you step through the code, when the first report node works and the second doesn't?

It's been a while, but is there an option to refresh the viewer?

With frmReports.crv
       .ReportSource = rpt
    End With

Author Comment

ID: 16705512
The refresh method fails - and causes an error :(

I have found some other threads that seem to lead to the conclusion that the CRViewer control can't be initialised directly, just on instantiation.
Also, I have a satisfactory solution in the unloading/loading procedure I outlined above.

Thanks for your input
LVL 101

Expert Comment

ID: 16705616
I believe your analysis is correct.  We use a similar nethod and I had to instantiate a new report application each time.  I also had to be sure to remove them from memory


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question