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!

Programmatically changing links - in CR 8.5

Status
Not open for further replies.

marmun

Programmer
May 10, 2001
4
CA
Hi Everybody,

Is it possible to programmatically change a report's table links? And I mean opening an existing report, altering one property for all the links, then saving the resulting report. I don't seem to be able to do it. I'm trying to change the JoinType property of every TableLink object - so that inner joins become left outer joins, as part of migrating reports that use native connectivity to ODBC connectivity. Due to TableLink properties being read-only, I thought getting all link properties, changing the one I need, adding a new link based on the updated set of props, then deleting the old one would work.

Here's the (Foxpro) code I'm trying to run:

loCRApp = CREATEOBJECT('CrystalRuntime.Application')
loCRReport = loCRApp.OpenReport('c:\somereport.rpt')
loDatabase = loCRReport.Database

FOR i = loDatabase.Links.Count TO 1 STEP -1

loLnk = loDatabase.Links(i)

loDatabase.Links.Add(loLnk.SourceTable, ;
loLnk.DestinationTable, ;
loLnk.SourceFields, ;
loLnk.DestinationFields, ;
5, ;
loLnk.LookupType, ;
loLnk.PartialMatchEnabled, ;
loLnk.IndexUsed)

loDatabase.Links.Delete(i)

ENDFOR

The .Links.Add() call causes an 'OLE exception error: Exception code c0000005. OLE object may be corrupt'.


Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top