PDA

Click to See Complete Forum and Search --> : Methods in an Access Database


scottr
Oct 18th, 1999, 01:33 AM
Hi this is a pure access question:


I have the following procedure which will go through the tables and querries collection and find out what has been updated on a given date. This will then write to a database so that we have a log. The problem is the other objects (form, macros, modules) dont have the method .LastUpdated. And im not sure how to capture this information. Im aware that i could go to the system tables but i am trying to create a better method. Any suggestions.

As always thanks for the assitance

Scott

tampfrm()

' this will go through the tables and querries and each day record what was last updated

Dim dbs As Database
Dim rst As Recordset
Dim tdf As TableDef
Dim qdf As QueryDef
Dim frm As Forms
Dim dbUpdateName As String
Dim DbUpdateDate As Date
Dim dbList As String, qdfList As String

' Return reference to current database.
Set dbs = CurrentDb
Set rst = _
dbs.OpenRecordset("tbl", dbOpenDynaset)


' Enumerate through tables defination
For Each tdf In dbs.TableDefs
' Evaluate LastUpdated and DateCreated properties.


If Format(tdf.LastUpdated, "dd/mm/yyyy") = Format(Now, "dd/mm/yyyy") Then
dbUpdateName = tdf.Name
DbUpdateDate = Format(tdf.LastUpdated, "dd/mm/yyyy")


Next tdf
AddName rst, dbUpdateName, DbUpdateDate

' Enumerate through queries defination


For Each qdf In dbs.QueryDefs
' Evaluate LastUpdated and DateCreated properties.
If Format(qdf.LastUpdated, "dd/mm/yyyy") = Format(Now, "dd/mm/yyyy") Then

dbUpdateName = qdf.Name
DbUpdateDate = Format(qdf.LastUpdated, "dd/mm/yyyy")

End If
Next qdf
AddName rst, dbUpdateName, DbUpdateDate


rst.Close
dbs.Close

End Sub


' this funtion will update the database
Function AddName(rstTemp As Recordset, dbUpdateName As String, DbUpdateDate As Date)

' Adds a new record to a Recordset using the data passed
' by the calling procedure. The new record is then made
' the current record.
With rstTemp
.AddNew
!Name = dbUpdateName
!DateTime = DbUpdateDate
.Update
.Bookmark = .LastModified
End With

End Function