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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

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
Back
Top