Form directory needed.

  • Thread starter Thread starter Frank Martin
  • Start date Start date
F

Frank Martin

Does Access2003 keep a directory of forms and
other objects that can be referred to easily.
Like a comboBox.
Frank
 
I'd afraid I don't really understand what it is you're looking for.

You can get a list of all of the forms using code like:

Sub ListAllForms()
Dim objForm As AccessObject
Dim objDatabase As Object

Set objDatabase = Application.CurrentProject
For Each objForm In objDatabase.AllForms
Debug.Print objForm.Name
Next objForm

End Sub

To get a list of each form and the controls on that form, try:

Sub ListAllFormsAndControls()
Dim objForm As AccessObject
Dim objDatabase As Object
Dim frmCurr As Form
Dim ctlCurr As Control
Dim booWasOpen As Boolean

Set objDatabase = Application.CurrentProject
For Each objForm In objDatabase.AllForms
If objForm.IsLoaded Then
booWasOpen = True
Else
booWasOpen = False
DoCmd.OpenForm objForm.Name, _
View:=acDesign, WindowMode:=acHidden
End If
Debug.Print objForm.Name
Set frmCurr = Forms(objForm.Name)
For Each ctlCurr In frmCurr.Controls
Debug.Print " " & ctlCurr.Name
Next ctlCurr
Debug.Print
If booWasOpen = False Then
DoCmd.Close acForm, objForm.Name, acSaveNo
End If
Next objForm

End Sub
 
Thank you. I was hoping that every
form/table/query/macro had an object ID which
could be referred to in the properties tab
(tag).

I will checkout the code below.



"Douglas J. Steele"
message
 
No, there is nothing like that. But, you can get the results in a
query:

Select Name,Type from MSYSOBJECTS

You'll have to look at the types. I don't have my cheatsheet of the
types infront of me. But, all the forms are like: -326XX or
something. Tables (local) are type=1, queries type=5.

So, if you wanted a list of all tables in the database in a combobox,
use the following recordsource:

Select Name from MSYSOBJECTS where Type=1 AND left(name,4) <> 'MSYS'


That will give you all the non-system tables.


Chris Nebinger.
 
That will give the Tables, Queries, Forms, Reports, Macros and Modules, but
not the fields in the tables or queries, the controls on the forms and
reports, or the functions and subs in the modules.
 
True, when I read Forms & other objects from the OP, I assumed that I
would throw this trick into the mix.

If he wants all text boxes, combo boxes, subs, functions, etc., then it
is accessible through various collections, but I would wonder for what
purpose.


Chris Nebinger
 
Back
Top