Jul 2nd, 2009, 08:17 PM
VB6, Crystal 8.5 OCX, different database in subreport
I am using Crystal 8.5 OCX and VB6 to run some reports. Users run reports on different databases with the same table structures. All run from ODBC sources that change in name also. The reports are just rpt files on the hard drive that are run when the user wants them run.
The running is fine and I can change database locations without problems. But I have run across circumstances now that some reports have some subreports that have different ODBC drivers from the main report and therefore need to be changed differently. I won't always know what the subreport names are nor if they even exist in specifc reports. The code below is what I am using and it works to change the subreport connection. But I can't figure out how to determine what the current connection is when it was designed. If I know what the connection is when it is designed, I can redirect it to the proper new driver.
intNumSubs = crReports.GetNSubreports
For X = 0 To intNumSubs - 1
title = crReports.GetNthSubreportName(X)
.SubreportToChange = title
strCurrentConnect = 'want to add something here to find the _
current connection string and then make a decision to change it or not
.Connect = sConnect
My default solution that I believe will work is to force the naming of a subreport specifically to identify the subreports that need different ODBC drivers from the default change, but I am not the only programmer of reports so anyone could name a subreport anything and that is very difficult to change once designed.
So does anyone have any idea how I can get the connection string or the ODBC driver that the subreport was created on from a subreport (and I guess I will probably be interested in the main report also) before I change it?
Click Here to Expand Forum to Full Width
Survey posted by VBForums.