[AccessD] TOP FIVE MOST COMMON VBA ERRORS AND THEIR SOLUTIONS

Arthur Fuller fuller.artful at gmail.com
Sat Mar 14 16:01:32 CDT 2015


Susan,

It's a choice not worth choosing, but technically you are of course
correct. The question is, Why on earth would one choose not to go with
Option Explicit? And in fact, why would Access offer it Off as the default?
Aren't we trying to educate developers in the right way to do things?

That said, I must also add that I no longer subscribe to the convention
that every variable should be declared at the top of any given sub or
function. After decades of experience, I have come to the conclusion that
vars should be declared just before they are needed. You might ask, Why
have I adopted this convention, rather than the tried-and-true convention
of declaring everything up front, even though the declared variable might
not be used for several pages into the code? Well, I think that the way I
posed the question supplies its own answer. First, in terms of readability,
don't bother me with declarations whose relevance don't become important
until much later in the code; and second, if I want to be able to copy and
paste some really cool snippet, I want to avoid going to the top of the
module and grabbing one or two declarations, then returning to the snippet
of interest and copy/pasting that part. I've been there and done that way
too many times to count, and have instead adopted the convention "Don't
declare a variable until it's immediately required." IOW, the compiler will
figure it out.

On Sat, Mar 14, 2015 at 4:42 PM, Susan Harkins <ssharkins at gmail.com> wrote:

> Well...
>
> I disgree with part of 5) -- some of that stuff is beneficial when you
> start adding on and enhancing, changing... why take them out? Well, the
> Debug.Print anyway... that's just routine for me and I see no reason to
> take them out. They come in handy at all stages of the project.
>
> Option Explicit is a choice. I think it's convenient, but it's a choice.
>
> Susan H.
>
> On Sat, Mar 14, 2015 at 4:36 PM, Rocky Smolin <rockysmolin at bchacc.com>
> wrote:
>
> >
> >
> >
> >
> http://www.lugh-sci.com/blog/top-five-most-common-vba-errors-and-their-solut
> > ions?utm_content=buffer61fac
> > <
> >
> http://www.lugh-sci.com/blog/top-five-most-common-vba-errors-and-their-solu
> >
> > tions?utm_content=buffer61fac&utm_medium=social&utm_source=linkedin.com
> &utm_
> > campaign=buffer#blogue>
> > &utm_medium=social&utm_source=linkedin.com&utm_campaign=buffer#blogue
> >
> > Of course, this isn't really necessary for us. :)
> >
> > r
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



-- 
Arthur


More information about the AccessD mailing list