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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 251k
  • Answers 251k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In your features/support/env.rb file there are some comments about this.… May 13, 2026 at 9:35 am
  • Editorial Team
    Editorial Team added an answer I would use a ThreadPool. Something like this: ThreadPool.SetMaxThreads =… May 13, 2026 at 9:35 am
  • Editorial Team
    Editorial Team added an answer a simple my $filename=__FILE__; print __FILE__; should do .. also… May 13, 2026 at 9:35 am

Related Questions

Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I want use html5's new tag to play a wav file (currently only supported
I didn't get the answer to this anywhere. What is the runtime complexity of
I didn't see any similar questions asked on this topic, and I had to
I didn't see the option to point the workspace (or it's VS equivalent, I'm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.