How to Display Multiple Descriptions from a Decode Table

Last reviewed: June 27, 1995
Article ID: Q109979
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, and 2.5b

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.