Microsoft KB Archive/140910

From BetaArchive Wiki
Knowledge Base


ACC: Using IIf() in Crosstab to Limit Column Headings (95/97)

Article ID: 140910

Article Last Modified on 1/19/2007



APPLIES TO

  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition



This article was previously published under Q140910

Novice: Requires knowledge of the user interface on single-user computers.


SUMMARY

You can use the IIf() function to group values under a small number of headings in a crosstab query. This article demonstrates how to group records by country and to count the number of orders placed for each customer.

NOTE: A demonstration of the technique used in this article can be seen in the sample file, Qrysmp97.exe. For information about how to obtain this sample file, please see the following article in the Microsoft Knowledge Base:

182568 ACC97: Microsoft Access 97 Sample Queries Available in Download Center


MORE INFORMATION

The following example uses the IIf() function to list companies whose name begins with the letter "A" individually, and to group all other companies under the "OTHERS" column heading:

  1. Open the sample database Northwind.mdb.
  2. Create the following new crosstab query based on the Orders table and the Customers table:

          Query: MyQuery
          ---------------------------------------------------------
          Type: Crosstab query
          Join: Orders.[CustomerID]<->Customers.[CustomerID]
    
          Field: Country
             Table: Customers
             Total: Group By
             Crosstab: Row Heading
          Field: IIf([CompanyName] Like "A*",[CompanyName],"OTHERS")
             Total: Group By
             Crosstab: Column Heading
          Field: Order ID
             Table: Orders
             Total: Count
             Crosstab: Value
  3. Run the query.


REFERENCES

For information about this same topic in Microsoft Access 2.0, please see the following article here in the Microsoft Knowledge base:

140910 ACC2: Using IIf() in Crosstab to Limit Column Headings

For more information about the IIF() function search the Help Index for "IIF Function."

Keywords: kbhowto KB140910