By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,164 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,164 IT Pros & Developers. It's quick & easy.

How do you generate a list of foms, reports and modules available in a database

P: n/a
I'm looking for a way with Visual Basic to generate a list of all the forms,
reports and modules within a database. I can currently generate a list of
tables and queries with the following code snipets see below. Anyone know a
simple way to do this?

Thanks
Dustin Wilson
Dim tbl As TableDef
Dim qry As QueryDef

For Each tbl In CurrentDb.TableDefs
Debug.Print tbl.Name
Next

For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name
Next
Nov 12 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I think you need to look in the Applcation object. There are AllForms,
AllRepors etc. collections there somewhere.

Pavel

Dustin Wilson wrote:

I'm looking for a way with Visual Basic to generate a list of all the forms,
reports and modules within a database. I can currently generate a list of
tables and queries with the following code snipets see below. Anyone know a
simple way to do this?

Thanks
Dustin Wilson

Dim tbl As TableDef
Dim qry As QueryDef

For Each tbl In CurrentDb.TableDefs
Debug.Print tbl.Name
Next

For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name
Next

Nov 12 '05 #2

P: n/a
Dim obj As AccessObject
Dim dbs As Object

Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
debug.print obj.Name
Next obj

For Each obj In dbs.AllReports
debug.print obj.Name
Next obj

For Each obj In dbs.AllModules
debug.print obj.Name
Next obj

For Each obj In dbs.AllMacros
debug.print obj.Name
Next obj

Set dbs = Application.CurrentData
For Each obj In dbs.AllQueries
debug.print obj.Name
Next obj

"Dustin Wilson" <dw*****@REMOVE.kgsgroup.com> wrote in message
news:41****************@news1.mts.net...
I'm looking for a way with Visual Basic to generate a list of all the forms, reports and modules within a database. I can currently generate a list of
tables and queries with the following code snipets see below. Anyone know a simple way to do this?

Thanks
Dustin Wilson
Dim tbl As TableDef
Dim qry As QueryDef

For Each tbl In CurrentDb.TableDefs
Debug.Print tbl.Name
Next

For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name
Next

Nov 12 '05 #3

P: n/a
Same idea, but use the Containers/Documents collection of the database
object.

Sub DebugPrintContainerItems(cntrName As String)
Dim doc As Document
Dim cntr As Container
Dim db As Database

Set db = CurrentDb()
Set cntr = db.Containers(cntrName)
For Each doc in cntr.Documents
Debug.Print doc.Name
Next doc

End Sub
"Dustin Wilson" <dw*****@REMOVE.kgsgroup.com> wrote in message
news:41****************@news1.mts.net...
I'm looking for a way with Visual Basic to generate a list of all the forms, reports and modules within a database. I can currently generate a list of
tables and queries with the following code snipets see below. Anyone know a simple way to do this?

Thanks
Dustin Wilson
Dim tbl As TableDef
Dim qry As QueryDef

For Each tbl In CurrentDb.TableDefs
Debug.Print tbl.Name
Next

For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name
Next

Nov 12 '05 #4

P: n/a
Pavel

That works great.. If anyone else is interested this was the code to list
all form. substituting AllTables, AllQueries, AllReports, AllMacros or
AllModules will list the other components of the database.

Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject

For Each obj In dbs.AllForms
Debug.Print obj.Name
Next obj

Thanks
Dustin Wilson
"Pavel Romashkin" <pa*************@hotmail.com> wrote in message
news:40***************@hotmail.com...
I think you need to look in the Applcation object. There are AllForms,
AllRepors etc. collections there somewhere.

Pavel

Dustin Wilson wrote:

I'm looking for a way with Visual Basic to generate a list of all the forms, reports and modules within a database. I can currently generate a list of tables and queries with the following code snipets see below. Anyone know a simple way to do this?

Thanks
Dustin Wilson

Dim tbl As TableDef
Dim qry As QueryDef

For Each tbl In CurrentDb.TableDefs
Debug.Print tbl.Name
Next

For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name
Next

Nov 12 '05 #5

P: n/a
This is exactly what I worked out from Pavel's post before your post
appeared, but this is exactly what I was looking for.

Thanks
Dustin Wilson

"Barry Edmund Wright" <ba*****************@NOSPAMrogers.com> wrote in
message news:EI*************@twister01.bloor.is.net.cable. rogers.com...
Dim obj As AccessObject
Dim dbs As Object

Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
debug.print obj.Name
Next obj

For Each obj In dbs.AllReports
debug.print obj.Name
Next obj

For Each obj In dbs.AllModules
debug.print obj.Name
Next obj

For Each obj In dbs.AllMacros
debug.print obj.Name
Next obj

Set dbs = Application.CurrentData
For Each obj In dbs.AllQueries
debug.print obj.Name
Next obj

"Dustin Wilson" <dw*****@REMOVE.kgsgroup.com> wrote in message
news:41****************@news1.mts.net...
I'm looking for a way with Visual Basic to generate a list of all the forms,
reports and modules within a database. I can currently generate a list of tables and queries with the following code snipets see below. Anyone

know a
simple way to do this?

Thanks
Dustin Wilson
Dim tbl As TableDef
Dim qry As QueryDef

For Each tbl In CurrentDb.TableDefs
Debug.Print tbl.Name
Next

For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name
Next


Nov 12 '05 #6

P: n/a
Dustin Wilson wrote:
I'm looking for a way with Visual Basic to generate a list of all the forms,
reports and modules within a database. I can currently generate a list of
tables and queries with the following code snipets see below. Anyone know a
simple way to do this?


I know this works in A97 (allForms etc doesn't):

select name, type from msysobjects where left(name,3)<>"~sq"

You have to do a little research to get at the meaning of type
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.