Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sum in Report field

1 view
Skip to first unread message

Welby

unread,
Jan 20, 2006, 6:04:02 AM1/20/06
to
A report developed - many years ago - in a Access 97 database, has as record
source a query called qrySalesResults. This query contains several fields
among others the fields code and amount. One of the textboxes in the report
contains this expression:
=Sum(Iif([code]=1, [amount], 0)
it worked perfectly under Access 97. It gets me the total of amount, of
those records in de recordsource where code is 1.

After conversion to Access 2002, this field generates an error:
3071 This expression is typed incorrectly, or it is too complex to be
evaluated. ...

I tried to replace the expression with this one:
DSum("[amount]", "qrySalesResults", "[code]=1")
I have to cancel the operation because no report showing even after 10
minutes.

So how to go from here?

Thanks

John Spencer

unread,
Jan 20, 2006, 9:18:55 AM1/20/06
to
You posted

=Sum(Iif([code]=1, [amount], 0)

Is that a typo - there is a missing ")" ?

=Sum(Iif([code]=1, [amount], 0))


"Welby" <We...@discussions.microsoft.com> wrote in message
news:EBC77C32-0031-4B2C...@microsoft.com...

Welby

unread,
Jan 20, 2006, 10:28:06 AM1/20/06
to
Is indeed a typo or rather a 'copypasto'

Welby

John Spencer

unread,
Jan 20, 2006, 12:01:54 PM1/20/06
to
I don't see any reason that this would fail. Anyone else?

"Welby" <We...@discussions.microsoft.com> wrote in message
news:AD9949C8-F953-4501...@microsoft.com...

Gina Whipp

unread,
Jan 20, 2006, 12:39:13 PM1/20/06
to
Just curious is the name of the field 'code'? Never a good idea.

But in any event, you might want to check your references.


"John Spencer" <spe...@chpdm.edu> wrote in message
news:e0w14MeH...@tk2msftngp13.phx.gbl...

Duane Hookom

unread,
Jan 20, 2006, 5:03:58 PM1/20/06
to
I'm surprise the IIf() was pasted in as Iif().
This should work if your references check out ok:
=Sum(IIf([code]=1, [amount], 0))
Another option is:
=Sum(Abs([code]=1)*[amount])

Is the Code field truly numeric?

--
Duane Hookom
MS Access MVP
--

"Gina Whipp" <n...@viruses.com> wrote in message
news:eD8muheH...@tk2msftngp13.phx.gbl...

0 new messages