How to Display Multiple Descriptions from a Decode Table

ID: Q109979

The information in this article applies to:

If you have a table with fields that have abbreviations, you can produce a report that gives a full description of each abbreviation alongside or in place of the abbreviation by using the following procedure:

1. Copy the following code into a .PRG file and run the code:

      CREATE TABLE DATA (code1 c(1), code2 c(1), code3 c(1))

      INSERT INTO DATA (code1, code2, code3) ;
         VALUES ("A","B","C")

      INSERT INTO DATA (code1, code2, code3) ;
         VALUES ("B","C","A")

      INSERT INTO DATA (code1, code2, code3) ;
         VALUES ("C","A","B")

      INSERT INTO DATA (code1, code2, code3) ;
         VALUES ("A","C","A")


      CREATE TABLE DECODE (code c(1), descript c(20))
      INSERT INTO DECODE (code, descript) ;
         VALUES ("A", "Apples, Airplanes")

      INSERT INTO Decode (code, descript) ;
         VALUES ("B", "Boys, Bananas")

      INSERT INTO Decode (code, descript) ;
         VALUES ("C","Church, cottage")
      INDEX ON code TAG code ADDITIVE

      CLOSE ALL
      SELECT 1
      USE data in 1
      USE decode IN 2 ORDER tag code

      USE decode IN 3 AGAIN ALIAS decode_3 ORDER TAG code

      USE decode IN 4 AGAIN ALIAS decode_4 ORDER TAG code

      SET RELATION TO data.code1 INTO decode ADDITIVE
      SET RELATION TO data.code2 INTO decode_3 ADDITIVE
      SET RELATION TO data.code3 INTO decode_4 ADDITIVE


      CREATE REPORT MULTIPLE

2. From the Report menu, choose Quick Report, and select the column layout.

3. Place a field to the right of the CODE1 field. Open the Expression

   Builder. From the table named DECODE, select the DESCRIPT field.

4. Place a field to the right of the CODE2 field. Open the Expression
   Builder. From the DECODE_3 table, select the DESCRIPT field.

5. Place a field to the right of the CODE3 field. Open the Expression
   Builder. From the DECODE_4 table, select the DESCRIPT field.

6. Save the report. From the Report menu, choose Print Preview. The preview
   should look like this:

      CODE1   A   Apples, airplanes
      CODE2   B   Boys, bananas
      CODE3   C   Church, cottage

      CODE1   B   Boys, bananas
      CODE2   C   Church, cottage
      CODE3   A   Apples, airplanes

      CODE1   C   Church, cottage
      CODE2   A   Apples, airplanes
      CODE3   B   Boys, bananas

Additional reference words: FoxDos FoxWin 2.0 2.50 2.50a 2.50b KBCategory: kbprg KBSubcategory: FxtoolGeneral

Last Reviewed: June 27, 1995