Share via

Orphaned Procedures

Anonymous
2022-12-21T11:29:09+00:00

Sometimes compiling doesn't reveal orphaned VBA procedures. Years ago, I deleted textboxes, comboboxes, etc. from forms, but did not check if there were event procedures for them. I have compiled, decompiled, and recompiled many databases since then, but my older ones will not reveal orphaned procedures when compiled. Is there a VBA to check for orphaned VBA procedures?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

George Hepworth 22,855 Reputation points Volunteer Moderator
2022-12-21T13:36:37+00:00

That's an excellent question, which I don't think has come up much before.

The short answer is that there is no explicit way to do that. Manually, you can check the modules behind all of your forms. Both orphaned Subs and Functions and Subs not attached to control events, will be listed at the top of the Declarations dropdown on the right side of the IDE.

That said, 3rd party tools like MZ-Tools can identify what it calls "Dead Code". That means there is a way to do it. However, it might be more efficient to just install a tool like that. MZ-Tools requires a paid license while other tools may be free.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
2022-12-21T13:36:35+00:00

No there is not, so compiling ALWAYS doesn't reveal orphaned VBA procedures :-)

There are commercial products that can find such code. Check with the FMS website. I think their Analyzer product can do this.

But there is no harm in just having them sit there. They won't execute.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-12-22T07:45:21+00:00

    FMS website.??? What's the UR? (There is more than one).

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-12-21T15:52:10+00:00

    but my older ones will not reveal orphaned procedures when compiled.

    Hi VWP1,

    You could change the name of the Sub or Function, and then a compile.

    If the code compiles smoothly, that Sub/Function was obsolete.

    This does not work for code in a linked code library, because the code can be called from a referencing database.

    Imb.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-12-21T15:46:12+00:00

    Thank you very much.

    If anyone out there knows of a free tool which does this, please offer it. However, MZ-Tools offers a free 30-day trial! Seeing that I KNOW I'll be using this for months, I'll probably end up buying it, for $63.

    Was this answer helpful?

    0 comments No comments