The information in this article applies to:
Novice: Requires knowledge of the user interface on single-user computers. This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp). SYMPTOMSWhen you use the Count function in a query, view, or stored procedure, Null values are ignored. RESOLUTIONThe resolution to this problem is different depending on whether you are working with a query in a Microsoft Access database (.mdb), or with views and stored procedures in a Microsoft Access project (.adp). Access database (.mdb)You can use the NZ() function to return another specified value when a variant is Null; therefore the count is of all records.To create a query and use the NZ() function, follow these steps:
Access project (.adp)Access projects do not support the NZ() function in views and stored procedures. Instead of the NZ() function, use the Transact-SQL statement, COALESCE. The COALESCE statement will return the first non-NULL expression from a list of expressions.The syntax of the COALESCE statement is as follows: COALESCE(expression 1, expression 2, ..., expression-n)where each expression will evaluate to either NULL or a value. The following T-SQL statement will return the same output as that listed above.
In this case, the COALESCE statement will return the value of Column2 if it is not NULL. If Column2 is NULL, it will return a zero, which will be used by the COUNT statement.
MORE INFORMATIONSteps to Reproduce Behavior
REFERENCESFor more information about aggregate functions including the Count function, click Microsoft Access Help on the
Help menu, type "perform calculations in a query" in the Office Assistant or the Answer Wizard,
and then click Search to view the topics returned. http://support.microsoft.com/download/support/mslfiles/sqlbol.exe Additional query words: prb
Keywords : kbusage kbdta QryOthr |
Last Reviewed: May 13, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |