Solved DSUM with multiple criteria (1 Viewer)

brunomesquita

New member
Local time
Yesterday, 17:25
Joined
Jun 1, 2021
Messages
9
Hello everyone.

I'm having problems with a balance query I started. So far, I got it working with two criteria. My problem is when I add my third one [TrainingRequestStatus]="Approved".

Code:
Balance: Val(DSum(Nz([AmountCredit],0)-Nz([AmountDebit],0),"qryTransactionsExtended","[EmployeeID]=" & [tblTransactions].[EmployeeID] & "AND [TransactionID]<=" & [TransactionID] & "AND [TrainingRequestStatus]='Approved'"))

What is wrong with my formula?

Help, please.
 

plog

Banishment Pending
Local time
Yesterday, 19:25
Joined
May 11, 2011
Messages
11,646
Are you sure it works with 2? You need to put a space before each AND
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:25
Joined
May 7, 2009
Messages
19,245
you also need to add quote to the first argument of Dsum():

Balance: Val(DSum("Nz([AmountCredit],0)-Nz([AmountDebit],0)","qryTransactionsExtended","[EmployeeID]=" & [tblTransactions].[EmployeeID] & " AND [TransactionID]<=" & [TransactionID] & " AND [TrainingRequestStatus]='Approved'")) & "")
 

brunomesquita

New member
Local time
Yesterday, 17:25
Joined
Jun 1, 2021
Messages
9
Are you sure it works with 2? You need to put a space before each AND

Balance: Val(DSum("nz( [AmountCredit] ,0)-nz( [AmountDebit] ,0)","qryTransactionsExtended","EmployeeID =" & [tblTransactions].[EmployeeID] & "and [TransactionID]<=" & [TransactionID]))

Yes, this formula is working fine, I don't know how to add the third criteria.
 

brunomesquita

New member
Local time
Yesterday, 17:25
Joined
Jun 1, 2021
Messages
9
you also need to add quote to the first argument of Dsum():

Balance: Val(DSum("Nz([AmountCredit],0)-Nz([AmountDebit],0)","qryTransactionsExtended","[EmployeeID]=" & [tblTransactions].[EmployeeID] & " AND [TransactionID]<=" & [TransactionID] & " AND [TrainingRequestStatus]='Approved'")) & "")

Hey @arnelgp, thanks for the reply.

I did wrap it up with quotes, but I still got the same error. At the end of your formula, it looks like you have one-too-many parenthesis.

Cheers,

Bruno.
 

brunomesquita

New member
Local time
Yesterday, 17:25
Joined
Jun 1, 2021
Messages
9
Guys, I figured it out... @arnelgp put me in the right direction. Here is the working formula:

BalanceApproved: Val(DSum("Nz([AmountCredit],0)-Nz([AmountDebit],0)","qryTransactionsExtended","[EmployeeID]=" & [tblTransactions].[EmployeeID] & " AND [TransactionID]<=" & [TransactionID] & " AND [TrainingRequestStatus]='Approved'"))

Cheers,

Bruno
 

Users who are viewing this thread

Top Bottom