Results 1 to 2 of 2
  1. #1

    Re: Getting the count for all modules or all macro

    I need help with a strange error I am running into here is just and example of some of the code

    Dim w, y, z, frm, rep, qry, tbl, modu, mac As Integer
    Dim check() As Boolean
    Dim accobj As Object
    Dim filepath As String
    Set accobj = CreateObject("Access.Application")
    MsgBox CurrentDb.Name
    xx = (Mid(CurrentDb.Name, 1, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & "Membrosia.mdb")
    accobj.OpenCurrentDatabase xx
    MsgBox accobj.CodeProject.AllModules.Count <------- says this is an illegal function

    Why is this creating an illegal function call for both this and AllMacros. I know I can do a accobj.CurrentData.AllTables.Count and I know I can do a CodeProject.AllModules.count so why is it throwing a hairy canary when I do this?

    Any help would be appricated.[img]/S/smash.gif[/img]

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: Getting the count for all modules or all macro

    I'm not even sure what your code is trying to do. You're declaring a bunch of variant variables in the first dim statement and then using an undeclared variable (xx) in the code. Then it appears that you're trying to open another instance of the current database in order to count its modules.

    If all you want is the count of modules in the current database, you're going at it the hard way. There isn't any need to use automation
    <hr>Set accobj = CreateObject("Access.Application")<hr>
    from within Access to get this kind of information. This should do it:

    <pre> lngModsCount = CurrentProject.AllModules.Count</pre>

    or, if you want the module count in a library database, use this:

    <pre> lngModsCount = CodeProject.AllModules.Count</pre>

    Of course, this only applies to Access 2000, since the AllModules collection is new to that version.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts