Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936

    Tracking changes to database - queries/tables/etc (not data)


    Does anyone know how to be able to track when a database object is changed? I'm thinking something along the lines of making a copy of the database when it is opened then do a comparison afterwards. Seems like a convoluted way and Access doesn't carry all information - it carries nothing to do with Macros, for instance, how can I see if a macro has changed?

    Any help/ideas/suggestions will be most welcome.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I suspect this would be difficult to impossible.

    Bing: Access track design changes

    http://bytes.com/topic/access/answer...design-changes
    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.

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Pity! Someone should write something for us!

    Thanks anyway.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    It's a Heisenberg effect.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You could possibly use DAO to go after objects like tables and queries using TableDefs and QueryDefs
    http://msdn.microsoft.com/en-us/libr...ffice.14).aspx

    You could collect data from the various properties and write the results to a table.

    Here is an example of enumerating field properties and writing the field properties of a given table name to a table. So you would do something like this only for the table defs and not the fields.
    https://www.accessforums.net/queries...tml#post205017


    To get other objects like Forms, Reports, Standard Modules, and Macros you could do something like this

    Dim objMacro As AccessObject
    For Each objMacro In CurrentProject.AllMacros
    Debug.Print objMacro.DateModified
    Next

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Thanks a lot! I will try that.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    So open db and execute code that saves various property settings into a table? What do you want to do with this data?

    Could also have code that identifies user when they open database and automatically enters username and date/time info into table.
    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.

  8. #8
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    I currently working on something like that for work. It doesn't track every single change so. It exports all objects as text to a git repository to get it under version control. Changes can be looked up by making diffs over the different versions. Not sure if this matches your use case. If so, let me know and I will ask my employer if I can distribute it under an open source lisence.

  9. #9
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    All these brilliant ideas! First I tried making copies of the tables and queries into another database on open, but it was taking way too long. Then I copied over just the structure of the tables (not interested in data) which quickened the process but is still taking rather long. On close I will have to check for differences, again this is going to take too long. Maybe hapm's idea of copying them as text files with version numbering might be better/quicker - hapm?

    Not yet "solved" - still in experimentation stage. Keep those ideas coming!

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Perhaps you can use a combination of things. For instance, in order to inventory objects and their modified date, you could do this via automation. A second DB could enumerate the production DB during after hours. The second DB could create an instance of the production DB.

  11. #11
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    By "create an instance", do you mean file copy or is there a better way?

  12. #12
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by aytee111 View Post
    By "create an instance", do you mean file copy or is there a better way?
    I mean instantiate an Object in the Second DB like this to access the members of the Original, production (live), DB.

    Code:
    Dim OtherDB As Object
    Set OtherDB = GetObject(strPath)
    OtherDB.Application.SomeMember
    I have not tried to do too much as far as methods and such but should be able to do just about anything, I would imagine.

  13. #13
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    There is a problem with the "export as text" approach for tables. I use the hidden sub Application.SaveToText to do the export, and this sub doesn't take tables. I wrote my own method for tables, but it isn't very fast as it iterates over every collection in the TableDef object and filters unneeded properties. The resulting file looks somewhat simmilar to the other files generated by Application.SaveToText, but as it is self written Application.LoadFromText doesn't take the file. If you want to import the table again, there would first be the need to write a seperate import function for it.

    To avoid exporting objects that didn't change, you can use the DateModified property of the AccessObject instance and compare it to a last exported date saved somewhere else. I use a custom property on the AccessObject that saves the last export date for this. It reduces the number of objects to export and therefor the time needed for the whole process.

  14. #14
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    So far I copy all objects to another database on both open and close (tables, queries and macros). For tables I use TransferDatabase/acExport which allows me to copy the structure only, saving quite a lot of time. For queries and macros I use CopyObject. It is easy enough then to do all the comparison logic in the logging database instead of in the production db.

    I don't know if it will be more efficient to check the DateModified/Created on the close of the prod db prior to making a copy of the object. This will entail extra work in getting hold of each object's properties and then checking to see if it had changed. I haven't tested this to see if would be quicker.

    One side effect, when checking the queries to see what exactly had changed, I am unable to access any of the fields or properties due to the fact that the queries won't run in the logging db - the source tables are missing. All I can do is compare the SQL. I break it up into subsections based on SELECT, FROM, etc to try to help the administrator, so that it isn't such a daunting task for them.

    It does take time to do all this while opening and closing the prod db. I have tried to get the developers to keep their databases clean by getting rid of all the unused objects - the ones called "_old" and "x..." and "test", the tables that are no longer used, etc. Not an easy task!

  15. #15
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    I'll be the buzz-kill guy in saying I don't see the need in context of the definition of what Access is and it's goal in being a departmental/small business solution..... so I can't consider it a flaw or criticism that this feature is not part of the core product.

    The product offers the accde format to lock the code so it can't be altered. The idea of allowing it to be altered but yet having a need to track every design change is very high level of version control that is just not appropriate for the product. IMHO....

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Tracking Changes In Database
    By data808 in forum Access
    Replies: 2
    Last Post: 03-25-2014, 12:21 AM
  2. Replies: 5
    Last Post: 04-23-2013, 08:07 AM
  3. Asset Tracking Database
    By wgroenewald in forum Access
    Replies: 3
    Last Post: 02-13-2012, 08:26 PM
  4. Adding data to tables using queries
    By HunterEngineeringCoop in forum Queries
    Replies: 3
    Last Post: 10-28-2010, 12:42 PM
  5. help with tracking within a database
    By martyn in forum Queries
    Replies: 0
    Last Post: 10-07-2009, 02:15 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
  •  
Other Forums: Microsoft Office Forums