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.
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.