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

Loading a .RPT file at Runtime with VB6/CR8.5

Status
Not open for further replies.

MikeDTI

Programmer
Mar 8, 2002
6
0
0
US
I've been trying to figure out if it's possible to load an external .RPT file into VB6 at run time. I don't want to use the Report control since there is no control over that object once it's displayed. I'm currently using ICRDesigners, but having to create one for every report we need to display is really a pain (plus making the program bigger and bigger). It would be nice to be able to import the .rpt files into the designer (or the CRViewer) at run time, but I haven't figured out how to do so yet.

Can anyone point me into the right direction for doing this?

Thanks,
Mike...
 
The method below works fine on CR 8.5 and probably on CR 8.0

dim cappAny as New CRAXDDRT.Application
dim crptAny as CRAXDDRT.Report

Set crptAny = cappAny.OpenReport(path of report)

Now you can play around with it to your heart's content.
 
Thanks that did help. But this led to one new problem.

In my code, I created the new report as in your example. I perform the following steps:

crptAny.DiscardSavedData
crptAny.Database.Tables(1).SetLogOnInfo dsn,dbname,username,password
crptAny.SQLQueryString = sSQL

The sSQL is a modified query that has the same table/fields that the rpt file was created with, but with a modified Where clause to meet user current selection. This worked fine when using the CRDesigner, but doing it this way, when the SQLQueryString is set, I get prompted for the Login Password, and then displayed the SQL String (but it's the original SQL string in the Rpt file).

Is there anyway around this?

Otherwise, thanks for the info, it got me a little further along.
 
First of all, what kind of database are you connecting to? In Crystal, make sure that Reprompt User When Connecting is not ticked.
Secondly, have you tried using the RecordSelectionFormula property instead of the SQLQueryString?
According to Crystal Decisions, when using the SQLQueryString in the RDC, it automatically runs the one stored with the report. This is a bug. They suggest using RecordSelectionFormula as this will not run the old SQL every time.
 
Thanks,
I'm connecting to an Oracle Database.
I just tried what you suggested about using the RecordSelectionFormula, but I'm having problems with that even with just testing. I guess I need to read up on it a little more to see if I can figure out how to set it correctly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top