PC Review


Reply
Thread Tools Rate Thread

How do I know which was the last time a table was updated

 
 
=?Utf-8?B?U0hB?=
Guest
Posts: n/a
 
      16th Jun 2004
I want to know how can I get, with VBA or Visual Script, the last time a table was updated, Wich property returns me that value?

Thanks,
Salvador Hernandez
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      16th Jun 2004
"SHA" <(E-Mail Removed)> wrote in message
news:B6714940-05D3-42EB-B852-(E-Mail Removed)
> I want to know how can I get, with VBA or Visual Script, the last
> time a table was updated, Wich property returns me that value?
>
> Thanks,
> Salvador Hernandez


If you want to know the last time any record in the table was added,
modified, or deleted, there is no property that gives that information.
The best you can do in that regard is either maintain a "LastModified"
date/time field in the table (but that doesn't help with deletions), or
else only allow the table to be updated by procedures that record audit
information in another table.

If instead you want to know when the table's *design* was last modified,
you can get that from a property of the DAO TableDef object; e.g.,

Dim db As DAO.Database

Set db = CurrentDb
Debug.Print db.TableDefs("Table1").LastUpdated
Set db = Nothing


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
=?Utf-8?B?U0hB?=
Guest
Posts: n/a
 
      16th Jun 2004
Dirk,

I tried your idea with the following code, but it did not work:
-----------------------------------------
'This is VBScript code
Set MyDB = CreateObject("ADODB.Connection")
'The ODBC Connection is called Transmisions
MyDB.Open "Transmisions"
'I want to know the last time table TransFor was modified
LastTime = MyDB.Table("TransFor").LastModified
MsgBox(LastTime)
MyDB.Close
-----------------------------------------
What am I doing wrong?

Thanks,
Salvador Hernandez
"Dirk Goldgar" wrote:

> "SHA" <(E-Mail Removed)> wrote in message
> news:B6714940-05D3-42EB-B852-(E-Mail Removed)
> > I want to know how can I get, with VBA or Visual Script, the last
> > time a table was updated, Wich property returns me that value?
> >
> > Thanks,
> > Salvador Hernandez

>
> If you want to know the last time any record in the table was added,
> modified, or deleted, there is no property that gives that information.
> The best you can do in that regard is either maintain a "LastModified"
> date/time field in the table (but that doesn't help with deletions), or
> else only allow the table to be updated by procedures that record audit
> information in another table.
>
> If instead you want to know when the table's *design* was last modified,
> you can get that from a property of the DAO TableDef object; e.g.,
>
> Dim db As DAO.Database
>
> Set db = CurrentDb
> Debug.Print db.TableDefs("Table1").LastUpdated
> Set db = Nothing
>
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      16th Jun 2004
"SHA" <(E-Mail Removed)> wrote in message
news:B6A7D3B0-956D-4ECD-AAA9-(E-Mail Removed)
> Dirk,
>
> I tried your idea with the following code, but it did not work:
> -----------------------------------------
> 'This is VBScript code
> Set MyDB = CreateObject("ADODB.Connection")
> 'The ODBC Connection is called Transmisions
> MyDB.Open "Transmisions"
> 'I want to know the last time table TransFor was modified
> LastTime = MyDB.Table("TransFor").LastModified
> MsgBox(LastTime)
> MyDB.Close
> -----------------------------------------
> What am I doing wrong?


As far as I know, the ADO Connectin object doesn't have a Table
collection. For this you'd need to use ADOX, and the Tables collection
of a Catalog object. Something like this:

Set cat = CreateObject("ADOX.Catalog")
cat.ActiveConnection = "Transmissions"
LastTime = cat.Tables("TransFor").DateModified
MsgBox LastTime
Set cat = Nothing

But I'm not really all that conversant with ADO and ADOX, so that may
not be exactly right.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
=?Utf-8?B?U0hB?=
Guest
Posts: n/a
 
      16th Jun 2004
Dirk,

Thanks for your help, I get an error message like this "Microsoft VBScript runtime error: 94, Invalid use of Null:'LastTime'", and this happens in the line with the instruction "MsgBox LastTime".

Salvador

"Dirk Goldgar" wrote:

> "SHA" <(E-Mail Removed)> wrote in message
> news:B6A7D3B0-956D-4ECD-AAA9-(E-Mail Removed)
> > Dirk,
> >
> > I tried your idea with the following code, but it did not work:
> > -----------------------------------------
> > 'This is VBScript code
> > Set MyDB = CreateObject("ADODB.Connection")
> > 'The ODBC Connection is called Transmisions
> > MyDB.Open "Transmisions"
> > 'I want to know the last time table TransFor was modified
> > LastTime = MyDB.Table("TransFor").LastModified
> > MsgBox(LastTime)
> > MyDB.Close
> > -----------------------------------------
> > What am I doing wrong?

>
> As far as I know, the ADO Connectin object doesn't have a Table
> collection. For this you'd need to use ADOX, and the Tables collection
> of a Catalog object. Something like this:
>
> Set cat = CreateObject("ADOX.Catalog")
> cat.ActiveConnection = "Transmissions"
> LastTime = cat.Tables("TransFor").DateModified
> MsgBox LastTime
> Set cat = Nothing
>
> But I'm not really all that conversant with ADO and ADOX, so that may
> not be exactly right.
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      16th Jun 2004
"SHA" <(E-Mail Removed)> wrote in message
news:39F93336-61DD-4E5A-89AF-(E-Mail Removed)
> Dirk,
>
> Thanks for your help, I get an error message like this "Microsoft
> VBScript runtime error: 94, Invalid use of Null:'LastTime'", and this
> happens in the line with the instruction "MsgBox LastTime".
>
> Salvador


I don't know what "Transmissions" is, in your code and configuration.
This works for me, to get the last-modifed date of a table named
"Table1" in a test .mdb file:

'----- start of code -----
Dim cat, LastTime

Set cat = CreateObject("ADOX.Catalog")

cat.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"C:\Documents and Settings\Dirk\My Documents\test.mdb;"

LastTime = cat.Tables("Table1").DateModified
MsgBox LastTime

Set cat = Nothing

'----- end of code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
timestamp in report: showing last time table updated Mitchell_Collen via AccessMonster.com Microsoft Access Reports 4 6th Dec 2007 04:33 PM
Is any .net updated required for the new daylight savigns time, or just update the OS is all that is needed? Do DateTime objects need to be updated in .net runtime? Daniel Microsoft C# .NET 2 14th Feb 2007 03:14 PM
Is any .net updated required for the new daylight savigns time, or just update the OS is all that is needed? Do DateTime objects need to be updated in .net runtime? Daniel Microsoft Dot NET 1 13th Feb 2007 02:17 PM
Loose time portion of date when table updated =?Utf-8?B?T2dldHR5?= Microsoft Access 2 22nd Jun 2006 07:34 PM
Form showing Time and Date a Table was updated adamevans81@gmail.com Microsoft Access 1 12th Apr 2005 11:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:27 AM.