Custom Toolbars in Access
Your Access database will look more impressive and be easier for
the users if you add some custom toolbars. One way of doing this is to
right-click on one of the existing toolbars and select
but it's safer to write some VBA code and let the application create
the toolbars for you. Microsoft Access gives you complete control of
these custom toolbars. You can create and destroy them and determine
whether or not they are visible to a particular user.
This example shows a simple Customer form with its own
toolbar. This toolbar has the correct Windows icons
and a tooltip and this familiarity will give the user more
confidence in the quality of the database you've developed.
References for a custom toolbar
The code that creates this toolbar is in the Load event of
the Customer form. Before writing any code you must ensure that
you have a reference to the right library. The toolbar and its
buttons are instances of a
objects and these are not part of the core of Microsoft
Access. You must tell Access where it can find them.
Open a code editing window and select
The contents of this list will vary with the software
already installed on your PC. You need to scroll down to
the block of Microsoft software and tick the entry
for the Microsoft Office Object Library. This example
shows an entry for Access 97 in Office 8.0.
Note that this reference will have to be updated if you
try to run this code on a machine running a different
version of Microsoft Office. If you copy the database to
a machine running Office XP then you will be able to open
the database with Access XP but you will get an error
message saying that it cannot find the Office 8.0
library. The solution is to open the code window on the
new PC, clear the Office 8.0 tickbox and tick the box
for the version of Office running on that PC.
The next page shows the VBA code needed to
create a custom toolbar.