Removing a form and all of the module code for it

  • Thread starter Thread starter Jack Gillis
  • Start date Start date
J

Jack Gillis

I have a form that I no longer use and would like to remove it and all
of its code in Modules. The first part is easy, but I've no idea how to
go about removing all the code unique to it in the Modules. What would
be the best way to go about discovering which code is associated with
that form and that form alone?

Thank you.
 
I would just delete the form and not worry about any other outside code that
may be associated with it. It is not as likely that procedures unique to
that form alone will be defined in standard modules. If you really insist
that all unique code be deleted, proceed as follows.

MAKE BACKUP COPIES

1. Turn on "Require variable declaration" in the options menu of the code
window.
2. Check for any global variables used on that form, but not declared there.
3. Look in the form too see if any outside procedure are called. Calling a
function will be proceeded by the word "Call" for user defined functions.
Right click on the function name and choose "Definition" to find the
associated code. Outside Subs are not proceeded by the word "Call", but can
be found the same way.
4. Do not delete any outside code yet, just mark the above with something
unique, like a comment with your initials and the date.
5. Delete the form, then compact the database.
6. Compile the database, correcting any undeclared variables.
7. Search for each of your marked comments, then do a search on each
variable or sub name that has been marked. If you find any, the code has
other use and can't be deleted. If not, go ahead and delete the unused code,
secure in the knowledge that you have good backups if things go wrong.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Thank you Arvin.

The code I am referring to, and I should have pointed it out, is the
code I created myself when I set up the data base. I recognize some of
it but not all.

Not worrying about that sort of code, code no longer needed, is one of
the things in my opinion that has led to today's software bloat.

Thanks again.
 
Are you talking about code that you created in the module assocated with the
form itself, or code that you created in a separate module? In other words,
when you open the code module, is its name Form_<name of your form> or is it
something else.

If the former, deleting the form will delete the module as well.

If the latter, then consider purchasing something like Total Access Analyzer
from FMS
http://www.fmsinc.com/products/analyzer/index.html
 
Douglas J. Steele said:
Are you talking about code that you created in the module assocated with the
form itself, or code that you created in a separate module? In other words,
when you open the code module, is its name Form_<name of your form> or is it
something else.

Thank you very much.

Good question! I suspect I put some of it in two or three modules I
created. Why I chose to do that modules, I haven't a clue becaue it was
so long ago (I'm talking about Acces 97 ) and it was my first attempt at
VBA.. But those modules probably include code not specific to the form
I want to delete.

With that in mind, I think the best approach would be to rename the
public subs and functions one by one and see what happens to determine
which are use only by the form in question.

I have since learned how to better organize the modules and did so in
subsequent db's.

Thanks again.
 
Back
Top