Dim objects and Set them rather than using lengthy references

The same mechanism that makes tip #14 so effective can be used on any DAO object. In general, it is faster to replace an expression like:


    dbEngine.Workspaces(0).Databases(0)

with


    Dim dbCurrent as database
    Set dbCurrent = dbEngine.Workspaces(0).Databases(0)

and then use the dbCurrent variable for all future references. If you only make the one reference in code, then there is nothing gained by creating a variable to store the reference, but more than two references is generally worth the overhead and extra lines of code.

Note that this is really only an issue for time critical portions of code. As for all optimizing, concentrate on the 10% of code that is used most, rather than worrying about rarely used routines.