How to Get Last Modified Date/Time for a Table

ssh

New Member
Joined
Dec 12, 2005
Messages
34
Hi, there,
I am trying to have a procedure get for me the date/time for when a table was last modified. I tried looking around on the web and on this forum but wasn't quite able to find what I was looking for.

The closest thing I found was the following code, which has the same idea, except it shows when a FILE or FOLDER was last modified. Any ideas on what I need to do to get the same info for a TABLE? Thanks!!

Sub ShowFileAccessInfo(filespec)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
s = UCase(filespec) & vbCrLf
s = s & "Created: " & f.DateCreated & vbCrLf
s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf
s = s & "Last Modified: " & f.DateLastModified
MsgBox s, 0, "File Access Info"
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
If you want to track modifications to records and tables, you need additional fields. I usually have at least two: CreateDate and ModDate.

Then, in a form where the data is edited, you need to go to the BeforeUpdate event of the form and insert this code:

Code:
If Me.NewRecord Then
   CreateDate = Now()
End If
ModDate = Now()
Whenever a record is created or edited, it is timestamped.
You can then run a Top 1 query on the table, sorting descending on ModDate, to get the timestamp for the last edit on the table.

Denis
 

wongm003

Board Regular
Joined
Aug 8, 2005
Messages
237
You could try...

Code:
Public Function date_created(strTblName) As Variant
On Error Resume Next

    date_created = Null
    date_created = CurrentDb.TableDefs(strTblName).DateCreated

End Function

Public Function date_modified(strTblName) As Variant
On Error Resume Next

    date_modified = Null
    date_modified = CurrentDb.TableDefs(strTblName).LastUpdated

End Function
 

ssh

New Member
Joined
Dec 12, 2005
Messages
34
Thank you, wongm003 and Denis. Both methods work great!
 

Forum statistics

Threads
1,136,927
Messages
5,678,621
Members
419,776
Latest member
mikelowski

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top