data type changes in a crosstab query

G

Guest

I have set up a crosstab query where the values are each the sum of a
particular amount in a table. The original data type for this amount in the
table is Currency, but the sums come out as Number in my query. I have the
equation listed as the Field, and Expression as the Total type. Why is the
data type different from the original, and how can I change it back?
 
A

Allen Browne

Open your crosstab query in SQL View (View menu, from query design).

On the first line, you will see something like:
TRANSFORM Sum(Amount) AS SumOfAmount

Typecast this with the CCur() to convert to currency.
CCur() can't handle nulls, so you also need to use Nz().

You will end up with the first line looking like this:
TRANSFORM CCur(Nz(Sum(Amount),0)) AS SumOfAmount

For other suggestions on how to get Access to understand calculated fields,
see:
http://allenbrowne.com/ser-45.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top