false Application.Modules.count

  • Thread starter Thread starter TNL
  • Start date Start date
T

TNL

Hi,
I use VB 6.0 to access an access 2000 DB, as following:

dim AccApp As Access.Application
Set AccApp = New Access.Application

AccApp.OpenCurrentDatabase "test.mdb"
With AccApp.Modules
For i = 0 To .Count - 1
debug.print .Item(i).Name
Next i
End With

The database test.mdb had 13 modules (4 standard and 9
classmodule, forms and reports), but the Modules.count
returns always only 6.

Why? Can anybody help me?

Thanks
TNL
Why
 
Hi TNL,

silly question but ...... are you sure that all of the
Forms/Reports have modules associated with them? If a
Form/Report does not have code behind it it will not be
counted.

hth

chas
 
TNL said:
I use VB 6.0 to access an access 2000 DB, as following:

dim AccApp As Access.Application
Set AccApp = New Access.Application

AccApp.OpenCurrentDatabase "test.mdb"
With AccApp.Modules
For i = 0 To .Count - 1
debug.print .Item(i).Name
Next i
End With

The database test.mdb had 13 modules (4 standard and 9
classmodule, forms and reports), but the Modules.count
returns always only 6.

The Modules collection only contains open modules.

If you want to refer to all the modules in a db, then start
with the container object in Containers("Modules") and loop
through its Documents collection.

With CurrentDb.Containers("Modules").Documents
For i = 0 To .Count - 1
debug.print .Item(i).Name
Next i

But this will not include the class modules associated with
forms or reports. To refer to those you have to go through
the Forms and Reports containers.

In A2K+, an alternative would be to use the AllModules
collection.
 
Back
Top