X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Modified Date For Objects, Any Version    
post Jun 24 2014, 01:25 PM

UtterAccess VIP / UA Clown
Posts: 32,213
Joined: 21-January 04
From: LI, NY

In the apps I've built for my company I have several standard objects, mostly forms, reports and modules. These are used in all my apps and I store them in a database of tools. However, from time to time I need to update some of these objects and I would like to propagate these changes to the production apps used by my company. So i wanted a way to check the modified date of the object and compare it to the date in the current app. If its later, then pull the latest version into the current app. I'm still working on the last piece, but thought sharing the first piece would be helpful to people:
Public Function fModDate(strObjectName As String, strObjectType As String, Optional strDB As String) As Date
Dim app As Access.Application
Dim db As DAO.Database
On Error GoTo Err_fModDate
If strDB = "" Then
    Set db = CurrentDb()
    Set app = Application
    Set db = DBEngine.OpenDatabase(strDB)
    Set app = New Access.Application
    app.OpenCurrentDatabase strDB
End If
Select Case UCase(strObjectType)
    Case "table"
        fModDate = db.TableDefs(strObjectName).LastUpdated
    Case "query"
        fModDate = db.QueryDefs(strObjectName).LastUpdated
    Case "form"
        fModDate = app.CurrentProject.AllForms(strObjectName).DateModified
    Case "report"
        fModDate = app.CurrentProject.AllReports(strObjectName).DateModified
    Case "macro"
        fModDate = app.CurrentProject.AllMacros(strObjectName).DateModified
    Case "module"
        fModDate = app.CurrentProject.AllModules(strObjectName).DateModified
End Select
    Set db = Nothing
    Set app = Nothing
    Exit Function
    MsgBox Err.Number & "-" & Err.Description
End Function

This version is specifically for the last modified date. But it could be easily modified for other properties. I may look into modifying it to pass the property making it more generic (or if someone wants to do so, feel free).
Two caveats to note here is that modules do not have individual modified dates. Since Access stores the modules into one large BLOB, whenever you change ANY VBA code, all the modules are updated with the same modified date. This is fine for my purposes, but may not suit others. Also, when you copy objects into a new database container, the objects will take on the create and modified dates at the time of import. Again, this doesn't affect my purposes as I need to check whether an object in the library file has a newer date. But it should be noted.
Oalso wanted to give thanks to Crystal and Jack (Leach) who provided direction I needed to get this working.
Anyway, hope this is useful for other people.
Go to the top of the page

Custom Search
RSSSearch   Top   Lo-Fi    23rd October 2018 - 08:48 AM