Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Detecting difference between fields Post Reply Post New Topic
Author Message
andyp
Newbie
Newbie
Avatar

Joined: 20 Sep 2010
Location: Germany
Online Status: Offline
Posts: 19
Quote andyp Replybullet Topic: Detecting difference between fields
    Posted: 20 Sep 2010 at 10:50am
I need to check to see if a difference exists between two fields from two different tables and if yes, I want to generate an error message.
Probably very simple when you know how!
 
I need to see if a difference exists between table 1 {location} against table 2 {location}
 
If difference then "error message"
 
Hope this makes sence, grateful for any help!!
 
andyp
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Sep 2010 at 11:07am
what item is the same in both tables that you know you are comparing the correct row from one table to the other?
IP IP Logged
andyp
Newbie
Newbie
Avatar

Joined: 20 Sep 2010
Location: Germany
Online Status: Offline
Posts: 19
Quote andyp Replybullet Posted: 20 Sep 2010 at 11:29am

Thanks for the reply, sorry if I have not explained myself very well, 

I have a prime table with a field called location
The location field has a table behind it and users need to select the correct table entry when setting up a master record.
Example: location A
 
A sub record also needs to be created which is then attached to the master record in order for it to become a live account.
 
Normally the location will come across from the master record to the sub record by default during the make live process.
 
As an option users can overwrite the sub record location if required as it may differ in exceptional circumstances.
 
If however a difference exists I need to pick this up during my validation process.
 
I therefore need to check master record location against sub record location and if they are different (not often) then I need to generate an error message to bring this to the users attention, just in case they have made a mistake during input.
 
Both tables link to the same location entries therefore
if the prime table shows location A and the sub table shows location A - no error message.
 
If however prime table shows location A and the sub table shows location B then I need to generate a message.
 
I can generate basic if then else statements etc. but I have never tried the above task before.
 
Sorry this is so long winded, hope it makes sence!!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Sep 2010 at 4:00am
no prpblem. I believe the trick here is how you join the tables and what field you join the on. Usual DB design would have a primary key in the Master record which is used as a foreign key in the details record. If every record in the master table has one matching record in the detail table then do an inner join on the primary key to foreign key . If there are options where there are no matching rows (not the issue of non matching locations but no row at all) then you will need to do an outer join if you want to look for these also.
once you join the tables, assuming it is an inner join just do a select statement to llok for you non matching locations.
you will have to replace the real neames but it will look like...
NOT({master_table.location_field}={details_table.location_field})


Edited by DBlank - 21 Sep 2010 at 4:02am
IP IP Logged
andyp
Newbie
Newbie
Avatar

Joined: 20 Sep 2010
Location: Germany
Online Status: Offline
Posts: 19
Quote andyp Replybullet Posted: 21 Sep 2010 at 7:31am
Wow, thats great! thanks very much for the tips!
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.032 seconds.