Creating a Running Balance Query

I used Duane's version. My version gave the same amount on each record
So, that would be "Yes, Duane's version raised the error?"
 
You could try several troubleshooting steps. I would first open the immediate window (press Ctrl+G) and enter the following with a good account and valid ID.
?Val(DSum("Nz(Debit,0)-Nz(Credit,0)","qryCheckRegister","[Account] = '[known legitimate Acct]' And ID <= 1000')

If it works, try the query with above expression.
If it works, add a new column to the query
test: [Forms]![frmBankAccounts]![Account]
If you see correct value from the form, consider providing a sample database with just the required objects.
 
TBH I am surprised that (DSum("Nz(Debit,0)-Nz(Credit,0)", works. :)
 
Working on it.
Here's the DB. I converted text Account to AccountID. Thanks. I have two forms to select the checking account. frmBankAccounts is a bound main form with subfrmCheckRegister. frmSelectRegister has a combobox to select checking account and then opens form frmCheckRegister.
 

Attachments

I am using Vba to set the Balance on your Query, qryCheckRegister.
see the Order By of the query.
 

Attachments

If you balance is for a specific Account then the query and DSum() must be filtered for the specific Account. I don't believe you mentioned or were clear the balance was for a specific account. Try an expression like:
Code:
Balance: Val(DSum("Nz(Debit,0)-Nz(Credit,0)","qryCheckRegister","AccountID = " & [AccountID] & " AND ID<=" & [ID]))
 
Sorry, I was looking at the original poster’s comments. I guess this is why it is bad practice to highjack a post.
 
If you balance is for a specific Account then the query and DSum() must be filtered for the specific Account. I don't believe you mentioned or were clear the balance was for a specific account. Try an expression like:
Code:
Balance: Val(DSum("Nz(Debit,0)-Nz(Credit,0)","qryCheckRegister","AccountID = " & [AccountID] & " AND ID<=" & [ID]))
FrmSelectRegister sends a filter when it opens form frmCheckRegister.

Thanks
 
I am using Vba to set the Balance on your Query, qryCheckRegister.
see the Order By of the query.
It worker! I did try a function called FNBalance from another discussion but it didn't work because it didn't have the vba code. Thank you so much!
 

Users who are viewing this thread

Back
Top Bottom