Results 1 to 6 of 6
  1. #1
    Samson is offline Novice
    Windows 10 Access 2019
    Join Date
    Jun 2023
    Location
    Bristol, England
    Posts
    7

    Changing sign (+ or -) in an append query


    So, I have a Tenant Transaction table tblTenantTransaction which obviously contains transaction details for tenants.


    At the end of the month I want to be able to consolidate the transactions for that month by creating a carried forward (c/f) transaction and a matching bought forward (b/f) transaction on the first of the next month.


    I have been able to create the bought forward transaction as the Amount (value) of the transaction is the same sign (positive or negative) as the Sum of Amount in the append query.


    My problem comes when I try to create the carried forward transaction as I need to reverse the sign of the amount.


    I've tried many ways to get this to happen but to no success. I think it's time to call in the experts!


    ***************
    I've been trying to insert an image of the append query but the site keeps telling me I don't have permissions!?
    Any help on that, then I can show you the append query that works!
    ***************

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    I have been able to create the bought forward transaction as the Amount (value) of the transaction is the same sign (positive or negative) as the Sum of Amount in the append query.
    It's not usually considered to be good practice to save calculated data. Usually better to do the calculation whenever and wherever it is required.
    I've been trying to insert an image of the append query but the site keeps telling me I don't have permissions!?
    Any help on that, then I can show you the append query that works!
    You could just copy and past the SQL statement of the query.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    You have to upload pictures you can't simply paste them in this forum unfortunately, even though it looks like you can.
    You could paste the SQL of the query however as text.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Multiplying any signed value by -1 will reverse its sign.

  5. #5
    Samson is offline Novice
    Windows 10 Access 2019
    Join Date
    Jun 2023
    Location
    Bristol, England
    Posts
    7
    Ha! I knew it had to be something simple like that. Thank you very much, works perfectly.

    I've pasted the new SQL here just for reference:

    INSERT INTO tblTenantTransaction ( TenantID, Amount, TransactionDate, TenancyID, PropertyID, PropertyDivisionID, TransactionType, Description, TransactionStatus )
    SELECT DISTINCTROW tblTenantTransaction.TenantID, Sum(tblTenantTransaction.Amount)*-1 AS [Sum Of Amount], [Forms]![frmTransactionConsolidationCriteria]![EndDate].[Caption] AS Expr1, tblTenantTransaction.TenancyID, tblTenantTransaction.PropertyID, tblTenantTransaction.PropertyDivisionID, "BCF" AS Expr2, "Balance c/f" AS Expr3, "REC" AS Expr4
    FROM tblTenantTransaction
    GROUP BY tblTenantTransaction.TenantID, [Forms]![frmTransactionConsolidationCriteria]![EndDate].[Caption], tblTenantTransaction.TenancyID, tblTenantTransaction.PropertyID, tblTenantTransaction.PropertyDivisionID, "BCF", "Balance c/f", "REC", tblTenantTransaction.TransactionDate, Format$([tblTenantTransaction].[TransactionDate],'mmmm yyyy'), Year([tblTenantTransaction].[TransactionDate])*12+DatePart('m',[tblTenantTransaction].[TransactionDate])-1
    HAVING (((tblTenantTransaction.TransactionDate)>=[Forms]![frmTransactionConsolidationCriteria]![StartDate].[Caption] And (tblTenantTransaction.TransactionDate)<=[Forms]![frmTransactionConsolidationCriteria]![EndDate].[Caption]));

    The important bit is:
    Sum(tblTenantTransaction.Amount)*-1 AS [Sum Of Amount]

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Happy to help. Pretty basic math principle. Good luck with the project!

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

Similar Threads

  1. append query is changing values
    By sh5mg in forum Queries
    Replies: 4
    Last Post: 01-13-2020, 06:31 PM
  2. Replies: 11
    Last Post: 04-08-2015, 02:55 PM
  3. Replies: 5
    Last Post: 07-06-2014, 10:18 AM
  4. Replies: 2
    Last Post: 03-23-2012, 09:20 AM
  5. Replies: 22
    Last Post: 01-25-2011, 11:19 AM

Tags for this Thread

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