Results 1 to 7 of 7

Thread: Make a database having a history access table

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2010
    Location
    Manila
    Posts
    2

    Make a database having a history access table

    I'am making a medical databases.
    The database is needing another table in MS access to set it to history of all patients.
    Once i edit the existing record its history will be recorded and should be save in the history table in MS access and the the new that is being replace to the old record will be recorded in the Main MS access.
    how can i made it?

    Plz help me.. It will helps me a lots.
    Thankz.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,107

    Re: Make a database having a history access table

    So you are talking about two, pretty nearly identical, tables. When a new record is added, the existing record is moved to the other table, then the new record is added. Is that about right?

    I am dealing with a similar situation...sort of. Whenever changes are made to a record in one field, the previous state of the record needs to be saved and a new record created. In my case, it is also important to note when the change took place. Therefore, I have a CreationDate and a TerminationDate (actually, I don't, but that's close enough for this description) in the single table. When a record is written, the new record has the current date as the CreationDate and a Null for the TerminationDate. The previous record, if there is one, had a Null for the TerminationDate, and that is updated to the current date. Therefore, the current records can be obtained by querying for where TerminationDate Is Null, while any past information can be obtained by querying for the opposite, and they can be ordered sequentially by the CreationDate.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2010
    Location
    Manila
    Posts
    2

    Cool Re: Make a database having a history access table

    Quote Originally Posted by Shaggy Hiker View Post
    So you are talking about two, pretty nearly identical, tables. When a new record is added, the existing record is moved to the other table, then the new record is added. Is that about right?
    Yeah. were actually the same.. the old record will be moved into another table(History) and the new record will be replace to the old record.

    How can we do it?

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,107

    Re: Make a database having a history access table

    I would suggest not even trying to move the records. Heck, I'm not even sure that you really CAN move a record. Instead, create a new record in the history table using the values from the current record, then delete the current record from the current table. Alternatively, if you are using a dataset with datatables for both the current and historic tables, and the tables really are identical in structure, you might be able to detach a record from one and append it to the other. Adding it to the history table would be pretty straightforward once it has been detached from the first table, but I don't know that step.
    My usual boring signature: Nothing

  5. #5
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Make a database having a history access table

    If you used a different database than Access then you can do this very simply with Triggers. Have an update trigger that copies the old values to the history table with a timestamp of the update. SQL Server is available in a free Express version. Access can connect to and use this as its storage, apparently, so it's still (kinda) good if you're required to use Access.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Make a database having a history access table

    Moved To Database Development

  7. #7
    Junior Member
    Join Date
    Jan 2011
    Posts
    25

    Re: Make a database having a history access table

    You can leave them in the same table. Simply have field EndTime. When a new record is created, record the current date/time in the existing record and then create a new record with endTime as Null.
    Last edited by baadil; Jan 30th, 2011 at 12:27 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
  •  



Click Here to Expand Forum to Full Width