jlibs
jlibs

Reputation: 13

DMIN in MS Access Query

My db is used to calculate commissions due to a salesperson. The commission percentage is tiered so that it increases as the total sales increase. For example, a salesperson is paid 2% if they hit $100 in sales, 3% if they hit $500, 4% if they hit $1000, etc.

The db has two tables used to calculate a salesperson's commission.

I need to create a query (or vba output to a table) combining these two tables that returns the earned commission amount per salesperson, calculated total sales in a given time period multiplied by the maximum rate for sales achieved.

I'm stumped. I've tried several ways to use a DMIN function but repeatedly get an "unknown" response when executing the query. The code following code works perfectly when I replace Sum([Sales].[value]) with a fixed number, but fails with the "unknown" error using the variable.

Sum([Sales].[Value])*DMin("Rate","CommissionRates","[Max_Amount] >=Sum([Sales].[Value])"

Any suggestions are greatly appreciated.

Upvotes: 0

Views: 1395

Answers (1)

VBlades
VBlades

Reputation: 2251

Looks like a variable concatenation error. Try this:

DMin("Rate","CommissionRates","[Max_Amount] >= " & Sum([Sales].[Value]))

Upvotes: 2

Related Questions