Results 1 to 2 of 2
  1. #1
    Orbit20 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    1

    Select Sum Query with multiple wheres

    Hello,



    I'm trying to create a select sum query with multiple where's.

    So far I have got:

    Balance: (SELECT Sum([Credit]+[Debit]) from tblTransactions as t where t.TrDate<=tblTransactions.TrDate AND t.Debit<=tblTransactions.Debit)

    This is designed to select "Credit" and "Debit" from the above records in ascending TrDate and Debit order. However, I want to extend this to include a third field called "Analysis Code"

    But just adding another AND criteria does not work.

    For example:

    Balance: (SELECT Sum([Credit]+[Debit]) from tblTransactions as t where t.TrDate<=tblTransactions.TrDate AND t.Debit<=tblTransactions.Debit AND t.Analysis Code<=tblTransactions.Analysis Code)

    Any suggestions how to add this third where?

    Thanks for the help (I have no clue about VBA!)

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Instead of trying to do this all in a query, have you considered building a report using grouping & sorting with aggregate calcs? Textbox in report has a RunningSum property.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-20-2011, 07:28 PM
  2. Replies: 1
    Last Post: 08-30-2011, 07:35 AM
  3. Multiple column select
    By oljees in forum Queries
    Replies: 2
    Last Post: 07-28-2011, 08:32 PM
  4. Select multiple items from list box
    By sharmaprashant22 in forum Queries
    Replies: 2
    Last Post: 05-05-2011, 12:18 PM
  5. Replies: 47
    Last Post: 06-17-2010, 03:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums