I’m making some significant changes to some VBA code, and some variables are being deleted and/or renamed. It would be a lot easier to find all the locations I need to update if the compiler would complain to me that the variables don’t exist instead of creating it on the fly.
How do I force VBA/Access to require variables to be declared?
You need to use
Option Explicitat the top of each VBA code module including forms and reports.You can set this for all future created modules and VBA code behind forms and reports by going into the VBA editor >> Tools >> Options >> Editor tab and ensuring Require Variable Declaration is checked.
From Access 2003 help:
I also use camel case when I Dim my variables.
ThisIsAnExampleOfCamelCase. As soon as I exit the VBA code line if Access doesn’t change the lower case variable to camel case then I know I’ve got a typo.