How to organize my code

  • Thread starter Thread starter Joy M
  • Start date Start date
J

Joy M

Hi -

Just wondering if anyone has any helpful hints on organizing code in the
VBE.

Is it a good idea to keep all procedures that are called by a module within
the module?
I read that this way the code is behind the form that uses it, which makes
sense to me.

Two things that I do are: use the shortcut menu to find Last Position.
Shift + F2 takes you from a call statement to the procedure.
Ctrl + Shift + F2 returns you to the call statement.

I still find it unwieldy. I keep my Form event procedures at the top and my
cmdButtons
at the bottom of the module.

If you are entering data in a form, the control event logic is in the same
order as the user encounters them on the form.

Right now I am in a big loop, which calls procedures which calls other
procedures.
Yes I put comments before each procedure. But it is all starting to look
the same.

Just wondering what you 'experienced' people do to 'tame the beast'.

Thanks!

Joy
 
well, i've never really tried to "organize" the VBA code. generally, if i'm
using a procedure in only one form, then i write it directly in the
form/report module. if i can modify it to serve multiple forms, i do that,
and store it in a standard module. if i'm writing a procedure, and decide to
split part of it into another procedure (either for use elsewhere in the
form/report, or just to cut down on the length of the procedure), i usually
write it either directly above or directly below the procedure that i'm
splitting it from.

usually when i'm working on form design, i go to my procedures via the
Properties box in design view, rather than opening the VBE directly and
searching for a specific procedure. if i need to find a procedure that's
being called from another procedure, i use the Find option in the VBE
window. i also make frequent use of bookmarks when i have to move between
multiple procedures, so i can just toggle between them.

hth
 
Back
Top