Results 1 to 4 of 4
  1. #1
    Miquel1 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    10

    Appending only records which have changed.

    Hi all,


    I'm trying to append to a table records from a query where only the records which have changed since the last time the query was run are appended.

    I have a query which counts and displays the number of animals in a specific colony (based on a table CALLED "MostRecentColony" where the fields are [PREVIOUS_COLONY], [CURRENT_COLONY] and [ANIMAL_ID]), excluding those whose [CURRENT_COLONY] is recorded as "Dead".


    Code:
    SELECT MostRecentColony.[CURRENT_COLONY], Count(MostRecentColony.[CURRENT_COLONY]) AS [CountOfCURRENT_COLONY]
    FROM MostRecentColony
    GROUP BY MostRecentColony.[CURRENT_COLONY]
    HAVING (((MostRecentColony.[CURRENT_COLONY])<>"dead"));
    I want to have a table which displays this data and is appended to, but only when the colony size (ie [CountOfCURRENT_COLONY] has changed since the last time the query was run. In this way I will be able to keep a running track of how colony sizes have changed over time.

    Any ideas?

    M

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    why would you do that? if you are keeping a history table that has the colony size over time you do not need to append this information to another table. Or are you saying that you are not keeping track (in your tables) of the colony size over time you are just updating the same field with a 'new' value every time you do a colony count?

  3. #3
    Miquel1 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    10
    Ah, I made a typo - the MostRecentColony is not a table, but a query. The source for this query is the table MainColonyMembership, which records the date animals were moved and where they were moved to. MostRecentColony tells me which animal is in which colony at any one time. Then my CountOfMostRecentColony (code above) runs off this to tell me how many animals are in each colony at present.
    So I can press a button to find out how many animals are in Group XX now, but if I wanted to know how many were in Group XX last month, I'd need a query that appends to a table the colony size whenever an animal changes colony. This is easy to do, but only if I want to append every colony & size whenever an animal changed colony - I can't work out how to append only the ones which have changed. Am I going about this the wrong way?

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    No you wouldn't need to do that at all if you are recording individuals being introduced to a colony and what date they were introduced to that colony you can produce a report by month that shows how many were added to the colony and the colony size (running sum), or at worst produce a report that shows the population at the beginning of the 'current' month and the population at the end of the current month. In this case there's no reason to append information to a temporary table or history table since you're already recording everything you need.

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

Similar Threads

  1. Appending records to a table
    By crowegreg in forum Programming
    Replies: 6
    Last Post: 08-13-2013, 09:54 AM
  2. Message before Appending Records
    By Lorlai in forum Programming
    Replies: 3
    Last Post: 03-19-2013, 04:51 PM
  3. Produce report after appending records?
    By Astron2012 in forum Access
    Replies: 14
    Last Post: 02-20-2013, 08:40 AM
  4. Appending inventory records with current price records
    By sberti in forum Database Design
    Replies: 8
    Last Post: 11-29-2012, 10:24 PM
  5. Key violation when appending records
    By slaterino in forum Programming
    Replies: 10
    Last Post: 08-26-2010, 08:25 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