To save design changes to Access-specific objects, such as
forms, reports, new page links, macros, modules, and commandbars, Access 2000
must lock the database exclusively during the Save operation. Tables, queries,
and relationships do not fall under this restriction because they are Microsoft
Jet-specific objects. Microsoft introduced this requirement to Access 2000 for
several reasons:
- Consistency with other Visual Basic Environment client
applications is provided.
- Dependency on the Jet database engine is
stopped.
- Stability of Access-specific objects is
improved.
Consistency with Other Visual Basic Environment Client Applications Is Provided
Because Access 2000 now hosts the Microsoft Visual Basic
Environment, the save model that is used by Microsoft Access must be consistent
with other applications that host the Visual Basic Environment. The Microsoft
Visual Basic Environment only permits exclusive editing and saving of Visual
Basic projects that are not under source code control. This is true of
Microsoft Visual Basic 6.0 and also all Microsoft Office applications that host
the Visual Basic Environment.
Dependency on the Jet Database Engine Is Stopped
Access 2000 now offers the ability to create Microsoft Access
project (.adp) files and also Microsoft Access databases (.mdb). Using an
Access project offers developers the ability to use Microsoft SQL Server as an
alternative database engine to Microsoft Jet. In the past, all Access specific
objects (forms, reports, macros, modules, and commandbars) were dependent on
the Jet database engine for storage. These objects were stored in
Access-specific system tables in the Microsoft Jet database. Because it is
possible for Access 2000 to use Microsoft SQL Server as an alternative to
Microsoft Jet, a storage mechanism had to be developed for Access-specific
objects that did not rely on the Jet database engine.
Stability of Access-Specific Objects Is Improved
The new project storage model improves the stability of
Access-specific objects and the Visual Basic project. Visual Basic for
Applications has never allowed multiuser editing of Visual Basic projects
without source code control. Microsoft Access 95 and 97 can circumvent this
restriction by hiding project changes that are made in a multiuser environment
from Visual Basic for Applications and then merge them into the project later.
However, this has the potential for affecting the stability of the Visual Basic
project. Therefore, Microsoft Access 2000 requires an exclusive lock when
designing Access-specific objects to make sure that the project has only one
editor.
Editing Microsoft Access Objects in a Multiuser Environment
Because users may open a database either for exclusive or for
shared use, the save behavior that is exhibited by Access depends on how the
user opens the database and if multiple users are currently accessing the
database.
If a developer opens the database for exclusive use, the
developer can save the design of any Access-specific object, provided that the
developer can open the database for read/write access and has the correct
permissions to modify the design of the object.
If a user opens the
database for shared use, the user can save the design of any Access-specific
object, provided that the user can open the database for read/write access, has
the correct permissions to modify the design of the object, and Access can
obtain an exclusive lock on the database.
Lock Promotion
To make sure there is exclusive use of the database, Access uses
the connection control feature of the Jet database engine to promote the user's
shared lock to exclusive. Access attempts to promote a shared lock to an
exclusive lock as soon as the user opens a form, report, macro, or commandbar
in Design view. Access attempts lock promotion at this time to prevent the
scenario where a user has made multiple design changes only to later find that
they cannot save them because Access cannot obtain an exclusive lock. By trying
lock promotion as soon as the user opens an object in Design view, Access can
warn the user if it cannot obtain an exclusive lock before the user makes any
design changes. Access does not try lock promotion when opening a module in
Design view. However, Access tries lock promotion as soon as the user edits any
module in the database.
Access maintains the exclusive lock until the
user saves or discards all dirty objects and no other objects are open in
Design view. Following this, Access demotes the lock back to shared if the
database was originally opened for shared use.
If Access cannot
promote the lock to exclusive when the user opens an object in Design view,
Access notifies the user with the message:
You do not
have exclusive access to the database at this time. If you proceed to make
changes, you may not be able to save them later.
Following this
warning message, Access opens the object in Design view and allows the user to
make design changes. If the user tries to save the object, Access tries to
promote the shared lock to exclusive. If lock promotion is successful, Access
saves the object and then maintains the exclusive lock until the user saves or
discards all other dirty objects and no object remains open in Design view. If
lock promotion fails, the user receives the following message:
You do not have exclusive access to the database at this
time. Your design changes will not be saved.
If the user tries to
close the dirty object and to save changes, then Access prompts the user with
the option of closing the object and discarding design changes made to it or
leaving it open and unsaved.
Steps to Reproduce the Behavior
- Start two instances of Microsoft Access on the same
computer.
- Open the sample database Northwind.mdb in both
instances.
- In the first instance of Microsoft Access, open the
Customers form in Design view. Note that you
receive the message:
You do not have exclusive access to
the database at this time. If you proceed to make changes, you may not be able
to save them later.
- Click OK to clear the message. Note that
the form opens in Design view.
- Add a text box control to the form.
- On the File menu, click
Save. Note that you receive the following message:
You do not have exclusive access to the database at this time.
Your design changes will not be saved.
- Click OK to clear the message.
- Close the second instance of Access on your
computer.
- In the first instance of Access, try to save the form
again. Note that the form is saved successfully.