Results 1 to 2 of 2
  1. #1
    barkly is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    23

    Append to existing records only

    Would appreciate some help with an append query.



    Context: Project relates to a share portfolio database where a monthly interest cost is incurred. The append query is used to distribute the monthly interest cost across all held stock in the portfolio proportionally.

    If I enter just one month of interest into tbl_Interest the append action distributes the costs into each stock. However if I enter two or more months of interest (into tbl_Interest) the append action then gives multiple entries of each record and their respective interest costs in my receiving table.

    All I want is for each month to append an updated value into the existing records should there be more than one month of interest cost data available – not the multiple entries.

    tbl_Interest holds each months’ interest.

    tbl_InterestCost holds the split of the monthly interest against each company held – (there may be thirty or forty individual companies in the port folio)

    The append action is to add the new monthly interest split values to the existing values.

    I thought the SELECT DISTINCT might have been an assistance but it wasn’t.

    The append query is here

    Code:
    INSERT INTO tbl_InterestCost ( TransactKey, MonthlyInterestSplit, LastUpdate, InterestCostKey )
    SELECT DISTINCT qry_Holdings.TransactKey, [MonthlyInterest]*[MyMonRatio]+[MonthlyInterestSplit] AS IntSplit, tbl_Interest.DateInterest, tbl_Interest.InterestKey
    FROM (qry_Holdings INNER JOIN tbl_InterestCost ON qry_Holdings.TransactKey = tbl_InterestCost.TransactKey) INNER JOIN tbl_Interest ON qry_Holdings.AccounID = tbl_Interest.AccountID
    WHERE (((tbl_Interest.Distributed)<>"Yes"))
    GROUP BY qry_Holdings.TransactKey, [MonthlyInterest]*[MyMonRatio]+[MonthlyInterestSplit], tbl_Interest.DateInterest, tbl_Interest.InterestKey;
    .

    Thanks

    barkly

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    INSERT is to add new records to a table.

    UPDATE is to modify existing records.
    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: 3
    Last Post: 08-28-2012, 02:27 PM
  2. Replies: 2
    Last Post: 05-21-2012, 08:46 PM
  3. Access 2007 - Creating New Records Based on Existing Records
    By GeorgeAugustinePhillips in forum Forms
    Replies: 9
    Last Post: 10-05-2011, 05:58 PM
  4. check existing records
    By zul in forum Programming
    Replies: 2
    Last Post: 08-24-2011, 03:41 AM
  5. Replies: 1
    Last Post: 05-18-2010, 11:43 AM

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