title: Crystal Report - Conditional selection of record
body: <p>I'm using Crystal Reports XI.</p>
  
  <p>My data is coming from a dataset.</p>
  
  <p>I have 2 tables which are related as follows:</p>
  
  <p>Product(ProdID(PK), ProdName)</p>
  
  <p>ProdPC(ProdPCID(PK), ProdID(FK), PCType, ProdCode)</p>
  
  <p>The 'PCType' field determins the type of barcode format the 'ProdCode' represents. (E.g. EAN13, EAN8).</p>
  
  <p>In crystal reports one 'Product' can have more than one kind of barcode which means my tables end up looking like this:</p>
  
  <p>Product: ("1", "Example Product 1")</p>
  
  <p>ProdPC: ("0", "1", "EAN8", "01234567"), ("1", "1", "EAN13", "012345678910")</p>
  
  <p>In crystal reports I only want to print 1 barcode label for per product. However because they're are 2 records in the 'ProdPC' table, I will get 2 labels being printed for this 1 product.</p>
  
  <p>What I want to do is place a condition in crystal reports which states, "If EAN13 is NULL then display EAN8, ELSE display EAN13"</p>
  
  <p>I do not have access to the dataset and cannot prevent the application which calls Crystal Reports to create the barcode labels from sending more than 1 record for the 'ProdPC' table.</p>
  
  <p>How can I create my conditional statement, purely in 'Crystal Reports 2008'?</p>
  
  <p>What I have tried so far is:</p>
  
  <pre><code>IF {PartPC.PCType} = "EAN-13" AND {PartPC.ProdCode} &lt;&gt; "" THEN 
      {PartPC.ProdCode}
  ELSE 
      /* DISPLAY PartPC.ProdCode containing EAN8 value */
  ;
  </code></pre>
  
  <p>But I am unsure how to then tell Crystal Reports to display the 'ProdCode' value where 'PCType' is equal to 'EAN8'</p>