adOpenStatic Logo
Navigation
Home
Resources
ASPMSAccess FAQ
Contact Ken
Copyright 2000 -




Make sure your constants are not conflicting
This may seem obvious to most people, but it does cause a number of errors.

For example if you wish to call the Recordset's .addNew method to add a new record to a table you can't open the recordset with an adLockReadOnly locktype, since that locktype creates a read-only recordset that does not support the addition of extra records.

This problem is commonly caused because either people use "magic numbers" (see Step 2) and are accidently using a ReadOnly locktype, or they don't specify a locktype and get the default (which is ReadOnly).

Another example is caused when you try to call the .UpdateBatch method without specifying the adLockBatchOptimistic locktype, instead I've seen people specify the wrong locktype, fail to specify a locktype (thus getting a readonly locktype) or misspell the locktype as adLockOptimisticBatch (presumably in line with .UpdateBatch).

The moral to all this is:
  • Always check your spelling!
  • Always use Option Explicit (to catch problems with undefined constants)
  • Always specify all the optional parameters in Functions and Subroutines - never rely on the defaults
Back to FAQ listing.