How can I get the last time a MS-Access table was modified?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
shamigc
Junior Coder
Posts: 37
Joined: Wed Oct 22, 2003 11:38 am
Location: Monterrey, Mexico

How can I get the last time a MS-Access table was modified?

Post by shamigc » Wed Jun 16, 2004 8:44 am

Hi,
I want to develop a script to audit the last time a Microsoft Access table was modified/updated, and I got the following code, but I receive an error :( in line "MsgBox LastTime", that says "Microsoft VBScript runtime error:94, Invalid use of Null: 'LastTime'". This is the code:
-----------------------------------------------
VBStart

Sub LastTimeModified

'This is VBScript code
Set Cat = CreateObject("ADOX.Catalog")
'The ODBC Connection is called Transmissions
Cat.ActiveConnection = "Transmissions"
'I want to know the last time table TransFor was modified
LastTime = Cat.Tables("TransFor").DateModified
MsgBox LastTime
Set Cat = Nothing

End Sub

VBEnd

VBRun>LastTimeModified
---------------------------------------------

How can I fix my code to get the last time a table was modified?
Thanks,
Salvador Hernandez
Thanks,
Salvador Hernandez

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Jun 16, 2004 3:36 pm

It looks like a sub routine vs. a function that will return a value.

Think you need to make it a function, something like this (untested):
VBSTART

Function LastTimeModified()

'This is VBScript code
Set Cat = CreateObject("ADOX.Catalog")
'The ODBC Connection is called Transmissions
Cat.ActiveConnection = "Transmissions"
'I want to know the last time table TransFor was modified
LastTime = Cat.Tables("TransFor").DateModified
MsgBox LastTime
Set Cat = Nothing

End Function

VBEnd

VBEval>LastTimeModified,LastTime

MessageModal>%LastTime%
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts