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

Crystal 4.6, VB6sp4, Access DB, dynamic db change at runtime

Status
Not open for further replies.

wexsoft

Programmer
May 9, 2002
8
EU
Hi folks

I have a report created with CR 4.6 (that comes with VB6) which connects to Access 2000 via ODBC. It runs fine within CR and via VB using Crystal ActiveX control. However, I want to be able to dynamically change the Access database that the report connects to at runtime. This is because the VB application can connect to different DBs depending on the value of an ini parameter, and the report needs to connect to the same db. Is this possible? I have tried changing the Connect property but the report still remains connected to the database defined at design time.

Thanks and regards

Billy Crosbie
 
Billy,

On the Crystal Decisions Support site:
go to the knowledge bank link and search for article: c2008324
"Changing the location of a ODBC File DSN at runtime" which gives you the code examples.


Hope this helps

paulmarr@arcom.com.au
 
Hi Paul

Thanks very much for the quick reply. Unfortunately that article didn't help as it just indicated I should change the Connect property which I've already done. It allows me to change the Connect property and I can display the new value in the VB app but when the .PrintReport method is invoked the report still points at the database that it was connected to at the time the .rpt file was created. The article you mentioned only refers to Crystal 8 (I'm using 4.6 as supplied with VB6 Enterprise Edition) so maybe they have made some changes to this functionality in version 8. I need it to work with version 4.6. The interesting thing is that the .SQLQuery method can be updated dynamically and does affect the records that are returned by the report, but it appears the .Connect property, although changed within the VB app, does not affect the original connection between the .rpt file and the db. Unless there is some other method or property that I need to invoke/set after changing the Connect property? I've tried the .Datafiles and .LogonInfo properties, but no joy. Maybe it cannot be done with version 4.6 of Crystal.

I'd appreciate any other suggestions you or anybody else may have.

Thanks and regards

Billy Crosbie
bcrosbie@wexsoft.ie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top