Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 259563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:16:28+00:00 2026-05-11T22:16:28+00:00

I didn’t design this table, and I would redesign it if I could, but

  • 0

I didn’t design this table, and I would redesign it if I could, but that’s not an option for me.

I have this table:

Transactions
    Index  --PK, auto increment
    Tenant --this is a fk to another table
    AmountCharged
    AmountPaid
    Balance
    Other Data

The software that is used calculates the balance each time from the previous balance like this:

previousBalance - (AmountPaid - AmountCharged)

Balance is how much the tenant really owes.

However, the program uses Access and concurrent users, and messes up. Big time.
For example: I have a tenant that looks like this:

Amount Charged | Amount Paid | Balance
      350            0            350
      440            0            790
       0            350          -350      !
       0            440          -790

I want to go though and reset all the balances to what they should be, so I’d have some sort of running total. I don’t know if Access can use variables like SP’s or not.

I don’t even know how to start on this, I’d assume it’d be a query with a subquery to sum all the charges/payments before it’s index, but I don’t know how to write it.

How can I do this?


Edit:

I am using Access 97

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:16:28+00:00Added an answer on May 11, 2026 at 10:16 pm

    Assuming Index is incremental, and higher values –> later transaction dates, you can use a self-join with a >= condition in the join clause, something like this:

    select 
      a.[Index], 
      max(a.[Tenant]) as [Tenant], 
      max(a.[AmountCharged]) as [AmountCharged],
      max(a.[AmountPaid]) as [AmountPaid],
      sum(
        iif(isnull(b.[AmountCharged]),0,b.[AmountCharged])+
        iif(isnull(b.[AmountPaid]),0,b.[AmountPaid])
        ) as [Balance]
    from 
      [Transactions] as a
    left outer join 
      [Transactions] as b on
        a.[Tenant] = b.[Tenant] and
        a.[Index] >= b.[Index]
    group by 
      a.[Index];
    

    Access SQL is fiddly; there may be some syntax errors above, but that’s the general idea. To create this query in the query designer, add the Transactions table twice, join them on Tenant and Index, and then edit the join (if possible).

    You could do the same with a subquery, something like:

    select 
      [Index], 
      [Tenant], 
      [AmountCharged], 
      [AmountPaid], 
        (
          select 
            sum(
              iif(isnull(b.[AmountCharged]),0,b.[AmountCharged])+             
              iif(isnull(b.[AmountPaid]),0,b.[AmountPaid])
              )
          from 
            [Transactions] as b
          where 
            [Transactions].[Tenant] = b.[Tenant] and 
            [Transactions].[Index] >= b.[Index]
        ) as [Balance]
    from 
      [Transactions];
    

    Once you have calculated the proper balances, use an update query to update the table, by joining the Transactions table to the select query defined above on Index. You could probably combine it into one update query, but that would make it more difficult to test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I didn't face this error before. I have a database db , that contains
Didn't know how else to put this. Say I have a JavaScript method that
I didn't expect this is that complex. But I can't figure out how I
(Didn't mean to create a new question, but revised the old one enough that
I didn't find an answer on the net and i hope this question have
i didn't tested this code on iPhone but i'm sure (tested) it doesn't works
I didn't find much in tutorials on this specific question.. So I have a
Didn't even know how to exactly phrase this question, but here is the the
I didn't really know how to phrase this question, its quite strange. I have
This didn't work: Setting the umask of the Apache user Arch doesn't have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.