false Application.Modules.count

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
 
C

chas

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
 
T

TNL

Hi chas,
yes, I'am sure. But even the count of standard modules
isn't not correct.

Thanks
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top