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 9178767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:37:48+00:00 2026-06-17T17:37:48+00:00

To set up the problem, I have to following 4 records in an Access

  • 0

To set up the problem, I have to following 4 records in an Access table used for keeping track of dues and registrions. This Table Name is “Transactions”

ID | Transaction Date | Transaction Name | Credit Account | Debit Account | Amount
1 | 9/1/2011 | 2011 Yearly Registration | Accounts Receivable | Income : Registration | 27
2 | 2/18/2012 | Registration Payment | Cash | Accounts Receivable | 27
3 | 11/1/2012 | 2012 Yearly Registration | Accounts Receivable | Income : Registration | 27
4 | 12/7/2012 | Registration Payment | Cash | Accounts Receivable | 27

(The Transaction Name field is really an ID field that has FK to another table where the actual name is stored. That will be shown in a minute).

I then created a query that would put those records into a format where I could sum the quantities to find out balances:

SELECT [Transaction Date], [Transaction Name], (select [Account Name] from Account_lookup where ID = Transactions.[Credit Account]) as Account , sum(Amount) as [Totals]
FROM Transactions
GROUP BY [Transaction Date],[Transaction Name],[Credit Account]
UNION SELECT  [Transaction Date],[Transaction Name],(select [Account Name] from Account_lookup where ID = Transactions.[Debit Account]) as Account, sum(Amount)*-1 as [Totals]
FROM Transactions
GROUP BY [Transaction Date],[Transaction Name],[Debit Account]
ORDER BY 3, 1 DESC;

The result of that is the following (The Income and Cash records have been stripped out because they’re not important for this problem). The query is called “Credit and Debit Account Totals”.

Transaction Date | Transaction Name | Account | Totals
9/1/2011 | 2011 Yearly Registration | Accounts Receivable | 27
2/18/2012 | Registration Payment | Accounts Receivable | (27)
11/1/2012 | 2012 Yearly Registration | Accounts Receivable | 27
12/7/2012 | Registration Payment | Accounts Receivable | (27)

So a query summing the Totals column should return 0. But it doesn’t.

When I run the following query on top of the query above (my query querying another query),

SELECT [Credit and Debit Account Totals].Account, Sum([Credit and Debit Account Totals].Totals) AS SumOfTotals
FROM [Credit and Debit Account Totals]
GROUP BY [Credit and Debit Account Totals].Account
HAVING ((([Credit and Debit Account Totals].Account)="Accounts Receivable"));

I get the following:

Account | SumOfTotal
Accounts Receivable | 27

If I change the sum to a count, then I get 3. I’m expecting a sum of 0, and a count of 4.

How can I get Access to use all 4 of my records? I’m guessing that somehow Access is ignoring the 2nd payment because the Transaction Name is the same, however Name isn’t part of the sum query and the Date field makes each row distinct overall in the first query.

I’ve tried putting ALL after the SELECT, but that didn’t work. Do I have to copy all the data to another table first – iow is Access getting confused by running a sum query on top of a union query? When I add date to the 2nd query, thus making each row distinct, I see all 4 records.

  • 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-06-17T17:37:49+00:00Added an answer on June 17, 2026 at 5:37 pm

    Take a step back. Change your first query :

    SELECT [Transaction Date], [Transaction Name], 
           [Credit Account] As Account,Amount 
    FROM Transactions
    UNION 
    SELECT [Transaction Date],[Transaction Name], 
           [Debit Account] As Account,Amount*-1 
    FROM Transactions
    

    Then

    SELECT [Credit and Debit Account Totals].Account, 
           Sum([Credit and Debit Account Totals].amount) AS SumOfamount
    FROM [Credit and Debit Account Totals]
    GROUP BY [Credit and Debit Account Totals].Account
    HAVING [Credit and Debit Account Totals].Account="Accounts Receivable"
    

    I think it all got too complicated with the layers of grouping.

    EDIT re comment

    SELECT [Transaction Date], [Transaction Name], 
           Account, Sum(Amount ) AS Total
    FROM (SELECT [Transaction Date], [Transaction Name],
          [Credit Account] As Account,Amount 
    FROM Transactions
    UNION 
    SELECT [Transaction Date],[Transaction Name], 
           [Debit Account] As Account,Amount*-1 
    FROM Transactions)  AS q
    GROUP BY [Transaction Date], [Transaction Name], Account
    ORDER BY 3, 1 DESC;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem. The background color in a ListView is set LightGreen
I am having the following problem: a) I have a UNIX build environment set
I 've been set the following problem and don't have a clue how to
My question is motivated by the following problem. I have a set of web
I have the following problem. I have a data set that has the beginning
I have a table with about 1.4 billion records, with the following format: mysql>
Folks, we have the following problem: we've got several objects containing table data that
Suppose I have a table with following records value text company/about about Us company
The problem: I have set of pictures, when the user presses on one of
Problem: I have a value that is set in $record, for instance 1.69. Then

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.