Storing copy of selected record


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Storing copy of selected record

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Storing copy of selected record

    [Originally posted by Peggy]

    Good afternoon!
    I am working on an Access 2000 application and I would like to save a copy of the selected record when a user makes a change on the form. I want to save it as it was prior to the change so I am attempting to use a combination of the form_dirty and the form_beforeupdate events. I want to put a copy of the orig record "somewhere" be that a variable or temp table so that I can either add the record to an archive table or replace the changed record with the original data depending on the user's response. I am pretty well stumped so any simplification you could provide would be deeply appreciated! :) Thanks!

    Peggy

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Storing copy of selected record

    [Originally posted by dannic]

    You must probably add some tables where you store the "history" of how the data has changed over time.

    These history tables will be quite large if changes are made often -:)

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Storing copy of selected record

    [Originally posted by HighCommander]

    You can keep a handle on the size of the history file, by keeping only the last one or two changes made. Index by date/time and whatever your key is so you will be able to find the oldest/most recent change.

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Storing copy of selected record

    [Originally posted by mike]

    1) Make a new table in the database - make it an exact copy of the table you want to be the "history" table. Remove all key-indexes (you can go with regular indexes if you need indexing) so that you wont have "unique record" problems. Name it somthing like "Data_History"

    2) When you want to "backup" a row of data:

    INSERT INTO Data_History
    (SELECT * FROM Data WHERE theIDField=SomeValue)




  5. #5
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Storing copy of selected record

    [Originally posted by Peggy]

    <<theIDField=SomeValue>>

    Thanks! That helps but I am still not sure how I can identify the IDField of the selected record. The selectedrecord property is the record number within the set so therefore not unique or static. Do you have any thoughts?

    Peggy

  6. #6
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Storing copy of selected record

    [Originally posted by mike]

    There must be some way of identifying the record. At the worst you'll have to modify the SELECT statment to say somethig like:

    INSERT INTO Data_History
    SELECT * FROM Data
    WHERE
    SomeField=SomeValue
    AND
    SomeOtherField = SomeOtherValue
    ..

    until you are sure to be able to select the correct record. Thats the beauty of setting up a table with some sort of unique value (like an AutoIncrement column) - then the SELECT has only one WHERE part.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center