Data Access Worldwide Knowledge Base
Article ID 2201 Article Title HOWTO: Change (delete/add) tablelinks in your report using Crystal RDC Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2201 KBase Category VDF11 Date Created 12/30/2005 Last Edit Date 01/02/2006
Article Text
QUESTION:
With the Crystal Reports RDC interface you can enumerate a lot of information from your reports as well as change information in your report. How can I change the jointype of the tablelinks in my reports? Should I use the ComAdd function in the cCrystalTableLinks class?
ANSWER:
You cannot directly change the jointype, you need to delete the original link and add it again.
The Crystal RDC documentation is quite light on how to do this. There is an example on ComAdd but it only shows how to setup a one-field-to-one-field link. If your relationship between child and parent table is based on multiple fields, the code fails and, even worse, the last executed ComAdd prevails.
How to change the jointype then?
First, we enumerate all the tablelinks and store the information in an array. Then, we delete the existing links in top-down order (this is needed because deleting a link causes higher numbered links to be renumbered). After this, the information from the array is enumerated and the contents of the source and destination field collections are placed in a variant array containing the dispatch IDs of the individual fields. While no information about this is given, it looks like field 1 of the source fields always links to field 1 of the destination fields. The array of source and destination fields is passed to the ComAdd function.
Watch out for side effects. So far I discovered that saving the report caused it to resize the page layout to the current paper size on the destination machine. Our DAW example reports are designed for a different papersize (probably letter or legal) than is valid in Europe (here it is the international standard A4). This means that after saving some part of the layout is outside the paper area. As you can see in the attached view, we needed to confirm the papersize to the one that was valid at design time. Maybe there are more side effects, so check the result very well before using this on all your reports and destroying the reports.
If you want to see how the example works, copy the view into the Appsrc folder of the order11_1 workspace, register the view in the Studio, load the view as source code and compile it. But before running create a child directory inside your data folder named ChangedReports because the ComSaveAs function used in the view assumes that directory is present.
NOTE: Using ComDelete and ComAdd require a Crystal Developer License at end-user side.
Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu
Web Links Related to this Article
File ChangeTableLinks.vw
URL=http://www.dataaccess.com/KBasePublic/Files/2201.ChangeTableLinks.vw
Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.
The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.