The information in this article applies to:
- Microsoft Access version 7.0
SYMPTOMS
Advanced: Requires expert coding, interoperability, and multiuser skills.
The ShowToolbar action does not show custom toolbars that are stored in
library databases, unless the library database is loaded as an add-in.
CAUSE
Microsoft Access version 2.0 and Microsoft Access version 7.0 differ in the
way they load library databases. For performance reasons, Microsoft Access
7.0 does not load a library database into memory until code in an active
application calls that library. Code in the library database can open
objects, such as forms and reports, but the ShowToolbar action will not
show or hide a toolbar unless the library database was loaded as an add-in.
RESOLUTION
The following example creates a database that can be loaded with the Add-in
Manager:
- Create a new database called Toolbars. Save it as type Add-ins (*.mda).
- If the system tables are not displayed, on the Tools menu, click
Options. On the View tab, click to select System Objects, and then
click OK.
- On the File menu, click Database Properties. In the Properties dialog
box, click the Summary tab, and then type "Custom Toolbars" (without
the quotation marks) in the Title box. Click OK.
- Create a new table called UsysRegInfo with the following structure:
Table: UsysRegInfo
----------------------------
Field Name: Subkey
Data Type: Text
Field Size: 255
Field Name: Type
Data Type: Number
Field Size: Long Integer
Field Name: ValName
Data Type: Text
Field Size: 255
Field Name: Value
Data Type: Text
Field Size: 255
- Enter three records into the UsysRegInfo table. The Subkey for all
three records should be:
HKEY_CURRENT_ACCESS_PROFILE\Menu Add-Ins\Custom Toolbars
The values in the other fields for each record should be as follows:
Subkey Type ValName Value
----------- ---- ------- -----
(see above) 0
(see above) 1 Expression =LoadToolbars()
(see above) 1 Library |ACCDIR\Toolbars.mda
- On the View menu, click Toolbars. In the Toolbars dialog box, click
New. In the New Toolbar dialog box, type "NewBar" (without the
quotation marks), and then click OK. Note that a new, blank Toolbar
appears. Click Customize, and drag a few buttons to the new, blank
Toolbar. Close the Customize Toolbars dialog box.
- Create a new module with the following function:
Function LoadToolbars()
DoCmd.ShowToolbar "NewBar"
End Function
- Compile and save this module.
- Close Toolbars.mda.
- Open the sample database Northwind.mdb.
- On the Tools menu, point to Add-ins, and then click Add-in Manager. A
list of available Add-ins will appear. "Custom Toolbars" will be in the
list if Toolbars.mda was saved in the Access directory. If it is not in
the list, click Add New, find and select Toolbars.mda, and then click
OK. Select "Custom Toolbars," and click OK. An X should appear to the
left of the library database in the Add-in Manager dialog box,
indicating that it has been installed.
- Close the Add-in Manager.
- On the Tools menu, point to Add-ins. Custom Toolbars should now appear
in the list of add-ins. Click Custom Toolbars. The new toolbar, NewBar,
should appear.
MORE INFORMATION
Steps to Reproduce Behavior
- Create a new database called Toolbars.mda.
- On the View menu, click Toolbars. Click New. Create a new toolbar and
call it NewBar. Click Customize. Drag a few buttons to the new toolbar.
Close the Customize Toolbars window.
- Create a new module with the following function:
Function LoadToolbars()
docmd.ShowToolBar "NewBar"
End Function
- Close Toolbars.mda.
- Open the sample database Northwind.mdb.
- Click the Modules tab and open the Utility Functions module in Design
view. On the Tools menu, click References. In the References dialog box,
click the Browse button, find, and click to select Toolbars.mda. Once it
is added to the available references list, click OK.
- Press CTRL+G to open up the Debug window.
- In the Debug window, type the following line, and then press ENTER:
?LoadToolbars()
Note that you receive the following error message:
Run-time error '2094':
Microsoft Access can't find the toolbar 'NewBar.'
NOTE: An easy way to make custom toolbars available to all databases is to
use the built-in Utility1 and Utility2 toolbars. In addition, custom
toolbars in other Microsoft Access databases can be imported into the
current database.
REFERENCES
"Building Applications with Microsoft Access for Windows 95", Chapter 12,
"Using Library Databases and Dynamic-Link Libraries", page 295, and Chapter
16, "Creating Wizards, Builders, and Add-ins", pages 359-375
For more information about creating and testing Add-ins, please see the
following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q143270
TITLE : ACC95: Creating and Testing Add-ins Paper Available on MSL
For more information about the UsysRegInfo table, search on "USysRegInfo"
using the Microsoft Access for Windows 95 Help Index.
For more information about using Utility Toolbars, search on "Utility
Toolbars," using the Microsoft Access for Windows 95 Help Index.
|