Create the USysRegInfo table How to
add-in menu Ms Access Gurus      

Tool > Add-in > How-To

This page is about creating and installing Microsoft Access Add-ins, and how to fix some of the errors that you might encounter.

Never made an add-in before? Its easy with a little knowledge, and a template you can download free

An add-in enables you run code in any database without having to create or import modules. Add-ins can save time and make your programs more accessible.

Add-ins aren't very well documented, and can be quirky to install, but when success happens, they're wonderful! I hope this page helps you, and saves you some frustration.

Run as administrator, USysRegInfo table, database properties, errors, code tips, etc.

Quick Jump

Install Steps

Run Access As Administrator

  1. Right-click on the MSACCESS.EXE file or a shortcut to it
  2. Choose "Run as administrator"

Open any database and launch the Add-in Manager

  1. On the DATABASE TOOLS ribbon tab, drop down the list under the Add-ins icon. Choose the Add-in Manager.

    open Add-in Manager from the ribbon

  2. OR
    Choose File > Options > Add-ins and then "Access Add-ins" from the Manage dropdown at the bottom. Click Go...

    open Add-in Manager from Acces Options

  3. Now the Add-in Manager dialog box shows.

    Add-in Manager dialog box

Install your add-in

  1. Click "Add New..."
  2. Browse to the ACCDA file and click Open.

    To be recognized as an add-in, the install file needs to have an ACCDA extension. This will start as another file that has been renamed such as an ACCDB or ACCDE file. Access recognizes the ACCDA file extension. When you open it, you can do anything you could before.

  3. Close the Add-in Manager.

Your add-in now appears on the Add-ins menu.

Add-in menu

Goto Top  

How to create an add-in

Steps

  1. Make a new database or use an existing database.
  2. Rename the file extension to ACCDA and open.
  3. Show System Objects.
  4. Create the USysRegInfo table and fill it out — or import and modify it
  5. If desired, specify database properties. Title, Company, and Comments are displayed in the Add-in Manager.
  6. Compile and Save the VBA code.

Goto Top  

Show System Objects

To see the USysRegInfo table that you'll be creating, you must set the Navigation Options to Show System Objects.

USysRegInfo for the DocumentSQL Add-in

Goto Top  

USysRegInfo table

The USysRegInfo table holds information for the Windows Registry. The USys table prefix means that this is a user system table, and you must create it — or import and modify it.

The USysRegInfo table should have the following data structure. I don't think the size of text fields matters, so you can make them shorter as long as they're long enough to hold what's needed.

Fieldname   Data Type   Size  Description  
Subkey   Text   255 name of the registry Subkey where setting is stored. HKEY_CURRENT_ACCESS_PROFILE\Menu Add-Ins will be expanded to the official Add-in path for your software and version  
Type   Long   4 type of entry. 0=key, 1=string, 4=DWORD  
ValName   Text   255 registry value name  
Value   Text   255 registry value  

Example USysRegInfo table

After you fill USysRegInfo with values, it might look something like this:

USysRegInfo for the DocumentSQL Add-in

Its okay to have extra records. Key, Library, and Expression are required. Subkey is the same for each record thats part of the same menu option. You can create multiple Subkeys, but instead of doing that, consider launching a menu form.

Goto Top  

Subkey

The Subkey field is the same on each record for items relating to a menu option. You can put multiple subkeys in the USysRegInfo table if you want multiple options on the drop-down add-in menu. My opinion, however, is that it is better to show the user a menu form so they can pick one of multiple options. This way, the add-ins list stays shorter.

Key, Library, Expression

UsysRegInfo needs records for these value names:

  1. Key (Type=0) to create the registry entry specified in the Subkey.
  2. Library (Type=1) to specify where the add-in file is stored and what its called. If you rename the ACCDA file, don't forget to change it here too. |ACCDIR will be replaced with the library path.

    Library Value is the path and filename. In this example, |ACCDIR will be expanded to the default library path for add-ins.

    • |ACCDIR\s4p_DocumentSQL.accda

  3. Expression (Type=1) is the name of a function (or a macro?) to run when the add-in is launched from Access. For instance, if this is the VBA function to run:

    VBA function for s4pDocumentSqlMenu

    then the Expression Value would be:

    • =s4pDocumentSqlMenu()

Goto Top  

Database Properties

Title, Company, and Comments are good to fill since they'll show up later in the Add-in Manager.

USysRegInfo for the DocumentSQL Add-in

Title, Company, and Comments are displayed in the Add-in Manager

USysRegInfo for the DocumentSQL Add-in

Goto Top  

How to Uninstall an add-in

If you wish to remove an add-in, for whatever reason, first uninstall it from Access. This removes information in the registry.

To remove an add-in from Access, select it and click Uninstall.

Uninstall an addin

The "x" indicator will go away when the add-in isn't installed.

Add-in not being used by Access

The file is still there even though it isn't being used. Its readily available in case you want to install the add-in again.

File still in the roaming folder

It is important to uninstall before moving or deleting the file from the library path so the registry values are deleted. Otherwise, you may end up with an error message you can't get rid of.

In my case, an add-in didn't complete its installation because the case-sensitive Subkey error (discussed below) bit me, but there was no add-in to remove.

Somewhere, however, an incomplete key must was made in the registry, so I got an error message about that. That error didn't affect using other add-ins, including one with the same name as the error. I found the bad key in the registry, deleted it, and the error went away.

Goto Top  

Registry

For my version of Access, the official registry key where add-ins are is:

Registry location for Access addin

HOWEVER, there is some discussion that if you expliticly specify a key, then Access won't dump add-ins when it updates.

If you export the Menu Add-ins key and its subkeys, you get a file like this:

saved registry file

HKEY_USERS\S-1-5-21-0123456789-0123456789-0123456789-1001 is the specification for HKEY_CURRENT_USER.

Goto Top  

Errors

Add-ins can be tricky to get to work, especially the first few times. There are some things that will cause an add-in not to install, and it may not always be the same! What has worked in the past might not work another time, and vice-verse,

New database sort order

'New database sort order' (Options, General) can be an issue. If necessary to change, compact and repair database for it to take effect. Choose General.

Capitalization

Subkey can be case sensitive. Start with
HKEY_CURRENT_ACCESS_PROFILE\Menu Add-Ins\.

Its ironic that "Add-Ins" might need to use capital "I" since the key name in the registry uses a lowercase "i".

UsysRegInfo

Make sure Key, Library, and Expression are specified in UsysRegInfo. Make sure their values are right. Ensure that subkey is correct and the same for all records of a menu option.

Bad State

If you get a "bad state" error, something might be wrong with a name. Check the file name in the UsysRegInfo table. Make sure that your VBA Project Name, Module name, and Procedure names are all unique.

Bad State Error because the file name was wrong

Avoid losing Add-ins with Updates

It seems that to avoid losing add-ins with updates, put a specific registry key in the Subkey field of the USysRegInfo table that isn't the version-specific path that Access will change.

Don't write to the Roaming directory!

This was unintentionally done during the AccessUserGroups presentation, and it caused Access to crash!

Use recordset instead of domain aggregate functions

In one of my add-ins, I was using DMax. Recently that had to be changed to use a recordset. Should have done it that way to begin with.

Goto Top  

Video

Making and Using Access Add-Ins (49 minutes, August 2020)

This presentation to the Lunchtime chapter of AccessUserGroups.org, hosted by Maria Barnes, is packed with information.

video on YouTube

How to Make and Install an Access Add-In (12 minutes, April 2019)

This covers basics of creating an add-in for Microsoft Access

Watch on YouTube

Watch on Experts-Exchange

Goto Top  

Code

Here are some code tips for your add-in.

Open a menu form

To open a form, specify the function name to run in the USysRegInfo table. In this case, Expression would be:

=LaunchMenu()

	Function LaunchMenu() 
	'200429 strive4peace
   	   DoCmd.OpenForm  "MyMenuFormname"
	End Function 

Refer to database

Anything you can do with a database object, like use a TableDef or OpenRecordset, will be done in whatever database you refer to.

— current database

To refer to the current database, use

	Dim db As DAO.Database 
	Set db = CurrentDb 
	'do stuff
	Set db = Nothing 

— code database

To refer to the code database, use

	Dim db As DAO.Database 
	Set db = CodeDb 
	'do stuff
	Set db = Nothing 

Make a blank database

      'make a blank database
      DBEngine.CreateDatabase sPathFileDatabase,dbLangGeneral 

Link to table in another database

   Function Link2TableOtherDatabase(psPathFileDatabase As String _ 
      ,psTablename As String) 
   'strive4peace
   'When you are using Make Table and Append queries,
   'use the optional IN clause to specify the path and filename of an external database.
   'Then use this procedure to link to the table

      'CALLS
      '  DropTheTable

      Dim db As DAO.Database _ 
         ,tdf As DAO.TableDef 

      'set db to be the current database
      Set db = CurrentDb 

      'if table is already in the current database, delete it
      Call DropTheTable(psTablename, db) 

      'link to table
      With db 
         Set tdf = .CreateTableDef(psTablename) 
         tdf.Connect =  ";Database=" & psPathFileDatabase 
         tdf.SourceTableName = psTablename 
         .TableDefs.Append tdf 
         .TableDefs.Refresh 
      End With 

      'release object variables
      Set tdf = Nothing 
     Set db = Nothing 
   End Function 

Here for code to DropTheTable, which is called by Link2TableOtherDatabase. It deletes a table if it is in the passed or current database.

Use CurrentProject to loop forms or reports in the Current database

   Dim AccessObject As AccessObject _ 
      ,Obj As Object  
	   
   Dim i As Integer _ 
      ,iCount As Integer _ 
	 
   ' --- Forms	
   iCount = CurrentProject.AllForms.Count 
   For i = 0 To iCount-1 
        Set AccessObject = CurrentProject.AllForms(i) 
        DoCmd.OpenForm AccessObject.Name,acViewDesign 
        Set Obj = Forms(AccessObject.Name) 
		  
        'do stuff
		  
        DoCmd.Close acForm,AccessObject.Name,acSaveNo		  
   Next i 
   
   ' --- Reports	
   iCount = CurrentProject.AllReports.Count 
   For i = 0 To iCount-1 
        Set AccessObject CurrentProject.AllReports(i) 
        DoCmd.OpenReport AccessObject.Name,acViewDesign 
        Set Obj = Reports(AccessObject.Name) 
		  
        'do stuff
		
        DoCmd.Close acReport,AccessObject.Name,acSaveNo		  
   Next i    
   
   'release object variables
   Set AccessObject = Nothing 
   Set Obj = Nothing 

Goto Top  

Download

Add-in Template for Access 365

Add-in Template for Access 2007

ListHotKeys Add-in that works!

Open Add-ins list

Goto Top  

Presentation

Access Pacific hosted by George Hepworth, 5 December 2024

Making Access add-ins by crystal

Making COM Add-ins with VSTO by Geoffrey L. Griffith

Goto Top  

Share with others

here's the link to copy:

https://msaccessgurus.com/tool/Addin_HowTo.htm

Goto Top  

Back Story

Add-ins are wonderful when they're working right! If you find yourself importing the same code over and over, consider turning it into an add-in!

When I started learning about Add-ins, there wasn't much good documentation on them, and still isn't. I hope this page will be a valuable resource for you, and prevent you from stumbling on the same things that I did!

Every now and then, something knocks out the installed add-ins even though the files are still there. In those cases, you just need to select each one and install what you want again. Alternately, you could back up and restore that branch of the registry, but I think I'd rather not do it that way.

Another gotcha: Ensure that the file you specify in USysRegInfo has the right name! I changed an ACCDB to an ACCDA and forgot to change that in the USysRegInfo table — not so easy to come back from.

If you get an error that I didn't mention, and fix it, please let me know what you did! Thanks ~

Goto Top  

Help

Are you looking for help?

Are you stumped? Do you want help? Let's connect! I love helping others.

Email me anytime at training@msAccessGurus.com
I look forward to hearing from you

~ crystal

Goto Top