Not very difficult. Here's an axample for tables.
Sub LastTdfMod()
Dim tdf As TableDef
For Each tdf In CurrentDb.TableDefs
MsgBox tdf.name & " " & tdf.LastUpdated & " " & tdf.DateCreated
End If
Next
Endif
Sub LastQDFMod()
Dim qdf As QueryDef
For Each qdf In CurrentDb.QueryDefs
MsgBox qdf.name & " " & qdf.LastUpdated & " " & qdf.DateCreated
End If
Next
Endif
For forms, reports, modules use Document. Ex:
Dim dbs As Database
Dim doc As Document
Set dbs = CurrentDb
With dbs.Containers!Forms
For Each doc In .Documents
Use !Script for Macros
I got the impression, when reading HELP on LastUpdated
and LastModified, the date returned would be the most recent
date changes were made to DATA in the table. I was more
interested in other database objects, though. Am looking forward
to trying your suggestions on form & report objects.
MLH
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
It would take you a few minutes examining the Object Browser. The use
of the Object Browser has been explained to you before. It seems you
have ignored the advice, in favour of posting questions here.
It took me less than a minute to find
Debug.Print DBEngine(0)(0).Containers("Forms")
("Categories").Properties("DateCreated").Value
Debug.Print DBEngine(0)(0).Containers("Forms")
("Categories").Properties("LastUpdated").Value
which show
1995-09-13 10:51:50
2007-08-05 11:22:27
for the form "Categories" in my copy of Northwinds.mdb in Access 2000.
It would take me perhaps two minutes to loop through all the objects
and retrieve these values for all the exposed objects in the db.
It might have taken you a little longer but not as long as waiting for
answers here.
If you were to practice using the Object Browser you might even be
able (and willing?) to answer a few questions.
And David might remove you from his killfile; and you might learn
something. But I guess we couldn't count on that.
Testing your posted example in my own MDB...
Debug.Print
DBEngine(0)(0).Containers("Forms")("frmMainMenu").Properties("DateCreated").Value
4/10/2007 9:18:37 PM
Debug.Print
DBEngine(0)(0).Containers("Forms")("frmMainMenu").Properties("LastUpdated").Value
8/6/2007 9:23:04 PM
That worked just as you said. Then I tried taking one more baby
step...
Dim dbs As Database, wsp As Workspace, ctr As Container, MyForm As
Form
' Return reference to default workspace.
100 Set wsp = DBEngine.Workspaces(0)
' Return reference to current database.
120 Set dbs = CurrentDb
' Return reference to Modules container.
140 Set ctr = dbs.Containers!Forms
MsgBox ctr.Count
160 For Each MyForm In ctr
180 Debug.Print MyForm.Name
200 Next MyForm
220 Set dbs = Nothing
Of course, I got an error in line #160. To enumerate the names of the
form objects in Container ctr - what syntax should I be using in lines
160 to 200? I thought the above would work - but it didn't.
' Return reference to default workspace.
100 Set wsp = DBEngine.Workspaces(0)
' Return reference to current database.
120 Set dbs = CurrentDb
' Return reference to Modules container.
140 Set ctr = dbs.Containers!Forms
160 For Each doc In ctr.Documents
180 Debug.Print doc.Name; " "; doc.LastUpdated
200 Next doc
220 Set dbs = Nothing
OK, the above works. Had to loop through documents, as it turned out.
So, there's my small contribution for the day.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
This works for me:
Dim pDocument As Document
For Each pDocument In DBEngine(0)(0).Containers("Forms").Documents
With pDocument
Debug.Print .Name, .DateCreated, .LastUpdated
End With
Next pDocument
A couple of things to consider here. The containers contains
documents, not the actual objects. The form documents "define", so to
speak, the forms (objects). In (early access like 97) there are no
forms until they are opened, using of course, the documents
definition. That's why the Forms.Count of your DB is zero unless there
are forms open. It's not that they're not counted unless they're open,
they don't exist until they're open.
Everybody except me loves CurrentDB. Try the above replacing
DBEngine(0)(0) with CurentDB. Problem! CurrentDB reinitializes itself
every time it's referenced. So it can't be used to loop. I know, we
can set a reference to it and use the reference. But why when
DBEngine(0)(0) works well and faster (probably not noticably). Oh you
think DBEngine(0)(0) might not be Current? C'Mon!!!!!!!!!! Oh you
think the leprechauns of Wizards might have DBEngine(0)(0) pointing to
another DB? Yeah, yeah, sure sure whatever. Who in his/her right mind
would actually USE a wizard (except those that sneak up on you) ? Blah
Blah Blah ... my motto ... "Don't let Micorsoft do anything for you
that you can do for yourself". Hey, Lyle, NO ONE agrees with you on
this matter so just SHUT UP.
> Everybody except me loves CurrentDB. Try the above replacing
> DBEngine(0)(0) with CurentDB. Problem! CurrentDB reinitializes
> itself every time it's referenced. So it can't be used to loop. I
> know, we can set a reference to it and use the reference. But why
> when DBEngine(0)(0) works well and faster (probably not
> noticably). Oh you think DBEngine(0)(0) might not be Current?
I am always suspicious of any paths to objects that are more than
two levels deep, so your:
DBEngine(0)(0).Containers("Forms").Documents
looks very dangerous to me. That's the kind of thing that leaves
implicit references open all over the place. I never navigate any of
the document collections without assigning the container to a
variable. You will notice that this is a practice followed quite
rigorously in all the Microsoft documentation for Access.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
I can't think of any reason at all that "DBEngine(0)
(0).Containers("Forms").Documents" should be dangerous. I've used that
particular syntax, and similar, a few billion times without any
problem. I suspect that one of the reasons is that I do not set an
explicit reference to the collection, and that there is no such thing
as an implicit reference, except in the imagination.
If something is followed quite rigorously in Microsoft Documentation
then, IMO, it's very likely to be ill-conceived, inefficient and just
plain crap. Where do they get these bozoes who write this crud,
anyway?
(Well, there goes my MVP nomination, eh?).
Ah well, I'm going into the wilderness for forty days now, David, so
don't bother to insult me about this. I won't read any response until
it's long dead, and I'll be busy with fasting and Satan tempting me,
anyway.
> I can't think of any reason at all that "DBEngine(0)
> (0).Containers("Forms").Documents" should be dangerous. I've used
> that particular syntax, and similar, a few billion times without
> any problem. I suspect that one of the reasons is that I do not
> set an explicit reference to the collection, and that there is no
> such thing as an implicit reference, except in the imagination.
Except for the fact that VBA uses reference counting and isn't 100%
accurate, I guess you're right.
All that rs.Close, Set rs = Nothing crap is just a waste of time, I
guess?
> If something is followed quite rigorously in Microsoft
> Documentation then, IMO, it's very likely to be ill-conceived,
> inefficient and just plain crap. Where do they get these bozoes
> who write this crud, anyway?
The fact is that a lot of the bugs that show up in Access would have
been avoided if one followed the practices established in the
documentation for Access. A long time ago I was annoyed at too many
variable declarations in those code examples, but now I understand
exactly why it's done.
Since Lyle is off in the wilderness being tempted to say something
nice about Microsoft :-):
Dim MyDB As DAO.Database
Dim MyForm As Document
Dim ctr As Container
Set MyDB = CurrentDb
For Each ctr In MyDB.Containers
If ctr.Name = "Forms" Then
For Each MyForm In ctr.Documents
MsgBox MyForm.Name
Next MyForm
End If
Next ctr
Set MyDB = Nothing
You can resume your argument when he gets back.
James A. Fortune
CDMAP...@FortuneJames.com
> Where do they get these bozoes who write
> this crud, anyway?
Surely, you do not expect anyone in this newsgroup to leap to their feet,
raise their hand, and shout, "Me, me, it was me!", do you?
Hope you enjoyed your camping trip... I'd been wondering why they were
preserving "Wilderness Areas" when "National Parks" were so nice, all things
considered... thanks for enlightening me that it is a place for developers
to go when they need forty days of fasting and temptation. Does anyone ever
_need_ that?
Larry