Try always to write "Option Explicit" at the beginning of each code.
This ensures the compiler that al variables must be defined with the Dim statement or within Subs, Functions, ...
You can set this as an option in the VB environment.