Print Page | Close Window

Linking Table Issue

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3126
Printed Date: 02 May 2025 at 12:39am


Topic: Linking Table Issue
Posted By: mrc161
Subject: Linking Table Issue
Date Posted: 07 May 2008 at 12:04pm
Hello.  Don't know if this is possible but want to ask:
 
I have 2 tables, Table A and Table B.  They each have account numbers that I need to link together, however, they are stored differently in each table.
 
As an example, say that Table A has account number stored as 123456789 in one field (call the field Acct).
 
However, in Table B, the same account number is broken out into two separate fields.  So in Table B, you have a field that has 1234 (call it Field 1), and then an entirely separate field that has 56789 (call it Field 2).
 
So I need to link the Acct field from Table A to a combination of Field 1 and Field 2 from Table B.  Does that make sense?
 
I can do it via a subreport (I create a formula merging Field 1 and Field 2 and then link that formula to Acct in the primary report), but I didn't know if there was another way.  I'm not a big fan of subreports and would like to avoid it if possible.
 
Thoughts?  Thanks, Mike



Replies:
Posted By: Lugh
Date Posted: 08 May 2008 at 5:40am
You can do it in SQL, using the SQL Command object to build your data source.

SELECT TableA.*, TableB.*
FROM TableA
JOIN TableB
ON TableA.Acct = TableB.Field1 + TableB.Field2


That's probably the simplest solution.



Print Page | Close Window