How to remove unused code

  • Thread starter Thread starter Jerry Crosby
  • Start date Start date
J

Jerry Crosby

If discovered that if I create a command button and edit what it does and
THEN change the name, I end up with a section of code for the old name that
no longer exists. Is there an easy way to search through your code and
delete all subs that refer to non-existant names?

Example: I create a command button using the wizard. It's automatically
given a name like "Command22" and creates a sub routine named
Command22_OnClick in the code. Later, if I change its name to "Print" it
will create a NEW blank sub routine named Print_OnClick and the subroutine
for Command22 remains, just taking up space.

The same thing happens if I create a command button and later delete it.
The underlying code remains.

Should I be doing something differently to keep my code from getting
cluttered? I know if I rename the button immediately before touching any of
the event code, I'm good. But I can't always think ahead like that!

Thanks in advance.

Jerry
 
Jerry

BACKUP, BACKUP, BACKUP first!

Open the "code-behind-form" window. Select the (General) Object from the
first drop-down box. Drop-down the Procedure (second) list -- the
procedures named after "old-name" objects, and shown under (General), are
disconnected from a no-longer-named object. Select one, highlight and
delete. Repeat until done.

Or, if you have extra money to throw at it, look into purchasing one of the
third party tools that help you find disconnect objects.

Regards

Jeff Boyce
<Access MVP>
 
Back
Top