Find the modified date of mdb file

J

James Bertino

i'm using this to find the modified date of my mdb file. what am i doing
wrong?
-------------------------
Public Function GetGeneralInfo(sPropName As String) As String

Dim dbs As Database
Dim cnt As Container
Dim doc As Document
Dim prp As Property

Const conPropertyNotFound = 3270
On Error GoTo GetGeneral_Err

Set dbs = CurrentDb()
Set cnt = dbs.containers!Databases
Set doc = cnt.documents!GeneralInfo
doc.Properties.Refresh
GetGeneralInfo = doc.Properties(sPropName)
GetGeneral_Bye:
Exit Function
GetGeneral_Err:
If Err = conPropertyNotFound Then
Set prp = doc.createProperty(sPropName, dbText, "None")
doc.Properties.Append prp
Resume
Else
GetGeneralInfo = "Sorry"
Resume GetGeneral_Bye
End If
End Function
 
J

John Vinson

i'm using this to find the modified date of my mdb file. what am i doing
wrong?

Probably nothing. Microsoft chose to update the "modified date"
whenever a .mdb file is opened. The date on which a design change is
made to any object in the database is not, to my knowledge, recorded
anywhere.
 
J

James Bertino

Well then John let me rephase my question. How can I programmatically check
to see when a table was last altered. I want to display this date so that
the user knows how old the information is when they run a querry. I know
that I could create an extra table and insert a Now() in a field and send
that file at the same time as the update of the other table. But I thought
it would be slicker if I could just look at the file's "Modified " date.

BTW -- I thought that the General page had three dates available;
Date Created
Date Modified
Date Accessed

Thanks in advance,
Jay
 
J

John Vinson

Well then John let me rephase my question. How can I programmatically check
to see when a table was last altered.

By:

a. Putting a DateModified or Timestamp date/time field in a table in
your database
b. Ensuring that the ONLY way to alter the contents of the table
you're tracking is using a Form that you control
c. Putting code in that Form's AfterUpdate event to update the
DateModified field.
I want to display this date so that
the user knows how old the information is when they run a querry.

"the information"? Do you want the most recent modification of ANY
record in the table (whether it was retrieved by the query or not) or
a separate date/timestamp for each record?
I know
that I could create an extra table and insert a Now() in a field and send
that file at the same time as the update of the other table. But I thought
it would be slicker if I could just look at the file's "Modified " date.

It would be slicker if Microsoft had implemented these fields in a way
that allows this, but alas they didn't.
 
J

James Bertino

John,
Here is something else I've been tiing to use
-------
Public Function GetModDate()
On Error GoTo DateCreatedXError
Dim sPath As String
Dim sFile As String
Dim cat As New ADOX.Catalog
Dim tblProducts As ADOX.Table

sPath = CurrentProject.Path
sFile = CurrentProject.Name

' Connect the catalog.
cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
"Data Source= sPath & sName ;"

With cat
Set tblProducts = .Tables("Products")

' Output
tblProducts.DateModified

End With

'Clean up
Set cat.ActiveConnection = Nothing
Set cat = Nothing
Exit Sub

DateCreatedXError:
Set cat = Nothing

If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If

End Function
----------
VB allows me to look at this data.
Also, this file is only modified before burned to a CD and distruted via
snail mail. The data is updated from a set of master files. The enduser can
only view the data. They can't even compact and repair.
Jay
 
J

James Bertino

John, I got it and here it is;
----------------------------------------
Public Function GetModDate() As String
Dim sPath As String
Dim sFile As String
Dim sFilePath As String
Dim sDataFile As Database
Dim tblProducts As TableDef
Dim test As String

sPath = CurrentProject.Path
sFile = CurrentProject.Name
sFilePath = sPath & "\" & sFile

Set sDataFile = OpenDatabase(sFilePath)
With sDataFile
Set tblProducts = .TableDefs!Products
With tblProducts
' Output
GetModDate = tblProducts.LastUpdated
End With
End With
End Function
__________________________________
And it really works.
Jay
 

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