In general you should keep the scope of the variable as tight as possible.
So if the var is only used in one procedure, declare (Dim) at the top of
that procedure's code.
If the var is used by more than one procedure, declare it at the module
level ie before any procedure code.
Another way to achieve the same effect is to declare the var as a parameter
to each procedure that will make use of it, then pass it from procedure to
procedure
Sub Proc1()
Dim variable as <whatever>
Call Proc2(variable)
End Sub
Sub Proc2(v As <whatever>)
MsgBox v
End Sub
Unlike some other languages, all VBA variables in a procedure are "dimmed"
regardless of where you do so. That being the case I prefer to do all of that
at the top of the procedure so they are all in one place.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com