DucDigital
DucDigital

Reputation: 4622

Sum of selected row in Access?

Just a question: Is it in anyway possible to get a SUM of selected row/cell on the fly in Access form?

I have a db like this:

  | ID | PRICE  |  TAX 
  |  1 |  20$   |   5$
> |  2 |  30$   |   6$
> |  3 |  40$   |   7$

Would it be possible to get the sum of row SUM(PRICE + TAX) in selected row (2,3).

I am using access 2007 and prefer something as native as possible, without using VBA since it's a networked DB and it's a bit hard to implement VBA in network DB. If there are no native access way of doing it then what's the VBA solution? Could it be possible if I migrate to MSSQL?

Upvotes: 0

Views: 289

Answers (1)

Gustav
Gustav

Reputation: 56026

You can add a boolean field to mark if the record is selected.

Then use this expression:

SelectedSum: Sum(IIf([Selected]=True,[Price]*[Tax],0))

or, if you prefer:

SelectedSum: Sum([Price]*[Tax]*Abs([Selected]))

Upvotes: 1

Related Questions