Link to home
Start Free TrialLog in
Avatar of ajmac-b
ajmac-bFlag for Australia

asked on

How to change the reportsource on a CRViewer control

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
       .viewreport
    End With

Any suggestions as to how to make this work consistently?
Avatar of janmarini
janmarini

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?
Avatar of ajmac-b

ASKER

Thanks for you reply
CR V 8.5
VB6 SP5
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.
ASKER CERTIFIED SOLUTION
Avatar of janmarini
janmarini

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ajmac-b

ASKER

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
Avatar of Mike McCracken
ajmac-b
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

mlmcc