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

Return Name of All Forms in Database

P: n/a
Hello,

Is anyone aware of a function that will return the name of all forms
contained in a database WITHOUT opening them. I have code that does it
(posted below), but you must open and close the forms...I do not want
this as there may be forms in use that should not be closed.

Dim db As Object
Dim ctr As Object
Dim doc As Object
Dim frm As Form
Set db = DBEngine(0)(0)
Set ctr = db.Containers!Forms
For Each doc In ctr.Documents
DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
Set frm = Forms(0)
frm.ShortcutMenu = False
Debug.Print frm.Name
DoCmd.Close acForm, doc.Name, acSaveYes
Next doc

Your help is greatly appreciated!

-Jeremy

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Here's a query which will do it:

SELECT Name FROM MSysObjects WHERE Type=-32768;

MSysObjects is a system table (one of several), which contains all sorts of
info about the database. If you want to explore further, turn on Show
System Objects in Tools | Options | View. The table doesn't have to be
visible for the query to work.

HTH,

Rob
"Jeremy" <sl********@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hello,

Is anyone aware of a function that will return the name of all forms
contained in a database WITHOUT opening them.

<snip>
Nov 13 '05 #2

P: n/a
Rob's query against the system table will definitely work, but there's no
reason you need to open the form to get its name using your code. You
already know the name of the form before you open it, otherwise you wouldn't
be able to open it! And, fwiw, I'd advise declaring the objects explicitly:

Dim db As DAO.Database
Dim ctr As DAO.Container
Dim doc As DAO.Document

Set db = DBEngine(0)(0)
Set ctr = db.Containers!Forms
For Each doc In ctr.Documents
Debug.Print doc.Name
Next doc

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Jeremy" <sl********@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hello,

Is anyone aware of a function that will return the name of all forms
contained in a database WITHOUT opening them. I have code that does it
(posted below), but you must open and close the forms...I do not want
this as there may be forms in use that should not be closed.

Dim db As Object
Dim ctr As Object
Dim doc As Object
Dim frm As Form
Set db = DBEngine(0)(0)
Set ctr = db.Containers!Forms
For Each doc In ctr.Documents
DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
Set frm = Forms(0)
frm.ShortcutMenu = False
Debug.Print frm.Name
DoCmd.Close acForm, doc.Name, acSaveYes
Next doc

Your help is greatly appreciated!

-Jeremy

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.