Auto-linking tables by key.

Tuesday 31 December 2013 @ 12:41 am

Whenever you have multiple tables in your report you need to specify the linking fields that connect the tables (the join). Crystal will often take a guess at the correct links using “auto-linking”. In recent versions of CR you can auto-link two different ways, “by name” or “by key”. CR tries “by name” as the default.  This works when the linking fields are the same name in both tables and when there are no other fields that have the same name between the tables. In my experience it correctly links the tables one out of three times. It more often adds extra links that break the join.  Just because Crystal has created a link you can’t assume that the link is correct.

But some databases are configured with primary and foreign key relationships that are visible through the database connection.  These databases allow Crystal to auto-link “by key” pretty reliably.  I tested it recently while working with a customer and was surprised that it could get enough information from the database to correctly link the tables. So how can you tell if your database supports this? This test will let you know:

1) Open a report that uses this database and that has at least two tables.
2) Open the linking window and click “Clear Links” on the right side.
3) Select the “By Key” option in the upper right.
4) Click the “Link” button.

If CR can’t retrieve the information from the database it will generate a warning message.  Otherwise it should create the appropriate links. Even when it works you are wise to verify the links are correct by checking the output from both tables on the report.

Feel free to let me know what your experience is with this.








Comments are closed.

Jeff-Net
Recrystallize Pro

Crystal Reports Server