This behavior occurs when a domain function returns a number. This behavior does not occur when you use domain functions on strings.
In many cases, you can avoid the behavior described in the "Symptoms" section by obtaining the results of the domain function through other means, such as by using the
Count() aggregate function in the
Total row of the totals query, or by using a standard select query instead of a totals query. For example, the following SQL statement causes the problem behavior:
SELECT Employees.EmployeeID, DCount("OrderID", "Orders", "[EmployeeID] = " & EmployeeID) As MyTotal
FROM Employees
GROUP BY Employees.EmployeeID, DCount("OrderID", "Orders", "[EmployeeID] = " & EmployeeID);
However, the following is a valid SQL statement that returns each EmployeeID from the Employees table and a count of the number of orders each employee has taken. This query uses the
Count() aggregate function to completely avoid the
DCount() function.
SELECT Orders.EmployeeID, Count(Orders.OrderID) As MyTotal
FROM Orders
GROUP BY Orders.EmployeeID;
You can get the same results by using the
DCount() function in the query, but by not using a totals query.
SELECT Employees.EmployeeID, DCount("OrderID", "Orders", "[EmployeeID] = " & EmployeeID) As MyTotal
FROM Employees;