Returning the last modified date of an object in Access 2002 and 2003

P

Paul Ponzelli

In VBA, docCurrObject.LastUpdated is supposed to return the modified date of
an object. However, it does not work in MSA 2000 and above. It usually
returns the create date of the object and not the modified date. This was a
known bug in Access 2000 (http://support.microsoft.com/kb/299554/en-us).
Several years ago, I received a solution to this problem from MS; however, I
cannot find it. Is there a solution for this in MSA 2002 and 2003?

Thanks in advance.

Paul
 
W

Wayne-I-M

Use DateModifield = Date()


Something like this on form afterupdate or beforeupdate


Private Sub NameOfForm_BeforeUpdate(Cancel As Integer)
On Error GoTo BeforeUpdate_Err

DateModified = Date

BeforeUpdate_End:
Exit Sub



Hope this helps
 
P

Paul Ponzelli

Thanks for the reply, Wayne, but I am actually looking for the modified date
of the object itself (example when the design of a form, report was last
modified). I may not have been very clear in my initial post so here is
some more information. If you look at the objects (Tables, Forms, Reports,
etc) in the Access database window you will see the object name,
description, the date last modified, and the date the object was created.
The modify date shows the date the object was last modified. This
information is available in VB using objectname.LastUpdated; however, in MSA
2000, 2002, 2003, there is a bug. Here is some sample code. You will
notice the objectname.LastUpdated is surrounded by ****. If you copy this
code into a db, modify one of your forms and run the code, you will see that
ObjectName.LastUpdated incorrectly returns the Create Date and not the
modified date. The bug is described in the MS link above, but only
references MSA 2000. Any help would be appreciated.

Option Compare Database
Option Explicit

Public dblocal As Database
Public dbactive As Database
Public dynactive As Recordset
Public strMasterdb As String
Public strTargetdb As String
Public varReturn As Variant
Public intMeterCounter As Long

Sub GetObjects()
' Routine to Get objects and tables from both the Master Db and the Target
db
' Loops thru and loads object information into tables

Dim dbactive As Database ' var representing active db (master or target)
Dim cntObjects As Container 'Var Container for Master db and Target db
Dim docCurrObject As Document ' Var Document for Master db and Target db
Dim ObjType As String ' var to hold object type
Dim i As Integer 'counter to loop thru Object types
Dim dynactive As Recordset 'Var holding Object Names for Master and Target
Dim j As Integer ' counter to loop thru Master and Target

Set dblocal = CurrentDb ' Set dblocal = this db

j = 0
i = 0

'***** Get Objects - Forms, Modules, and Reports for Master and Target
******

'If Forms!frmMain!grpSelectCriteria <> 5 Then 'check for tbl only options

'Loop twice to process master first then Target second
For j = 1 To 2
' Select between target and Master dbs and dyn.
Select Case j
Case 1 ' Set var to Master and loop
strMasterdb = "C:\Test\EditDateProblem"
Set dbactive = OpenDatabase(strMasterdb)
Set dynactive = dblocal.OpenRecordset("tbl_Master_Objects")
If Forms!frmMain!grpSelectCriteria = 6 Then
j = 3
End If
Case 2 'Set var to Target and loop
'Set dbactive = OpenDatabase(strTargetdb)
'Set dynactive = dblocal.OpenRecordset("tbl_Target_Objects")
End Select

'Loop and capture Forms, Reports, Modules
For i = 1 To 3
Select Case i
Case 1
ObjType = "Forms"
Case 2 '
ObjType = "Reports"
Case 3
ObjType = "Modules"
End Select

'set cntObjects = to master/target db forms/reports/modules
container
Set cntObjects = dbactive.Containers(ObjType)

'Setup Progress Meter
varReturn = SysCmd(acSysCmdInitMeter, "Analyzing " & ObjType,
cntObjects.Documents.Count)
intMeterCounter = 0

' Loop thru objects in container and write data to table
For Each docCurrObject In cntObjects.Documents
intMeterCounter = intMeterCounter + 1
varReturn = SysCmd(acSysCmdUpdateMeter, intMeterCounter)
dynactive.AddNew
dynactive!ObjName = docCurrObject.Name

'*****************************
dynactive!objLastModDate = docCurrObject.LastUpdated

'*****************************
dynactive!ObjType = ObjType
dynactive.Update
Next docCurrObject
Next i
Next j
'End If

'dynactive.Close
varReturn = SysCmd(acSysCmdRemoveMeter) ' Close Progress Meter

'Close out all Variables
Set docCurrObject = Nothing
Set cntObjects = Nothing
j = 0
i = 0
intMeterCounter = 0

On Error Resume Next
dbactive.Close
dynactive.Close

End Sub


Hope this helps.

Paul
 
P

Pieter Wijnen

the table MSYSOBJECTS has always stored the correct info

HTH

Pieter

SELECT NAME, DATECREATE, DATEUPDATE FROM MSYSOBJECTS
 
P

Paul Ponzelli

Good suggestion, Pieter. It works!

Thank you.


Pieter Wijnen said:
the table MSYSOBJECTS has always stored the correct info

HTH

Pieter

SELECT NAME, DATECREATE, DATEUPDATE FROM MSYSOBJECTS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top