MS Access: starting help from code

To add a Help button or menu with help options to your application, you have to add a little VBA code to your application.

Deploying the help: browser based help or CHM file

Before adding the code lies the decision on how to deploy the help. If you choose browser based help you can deploy your application without having to include any help files. If you choose HTML Help (CHM), you are giving your user a better help system. You then have to only include the chm file - not the individual topic (.htm) or other files.

Publishing the browser based help on your website gives you an excellent extra way to promote your application - SEO. You can do this independent of your decision to distribute a chm files with it.
You can import the required modules from the Microsoft Access demo database which you can download from here:

Look at the sample code

  1. Download the file Microsoft Access demo database.
  2. Unzip the contents in a folder (e.g. c:\temp\hgaccessdemo)
  3. Open the database acchelpDemo.mdb
  4. In the database there are Forms to show how to call the help, and some modules with supporting code modules and classes which you will need to add to your database.
  5. Open the form HelpToolbar in design mode
  6. Select the [Index] button (scroll down to the bottom of the form)
  7. Right-click on the button and select 'Build Event'
    This will take you to the code from the button which is used to open the Help File with the Index tab selected.

    Private Sub cmdIndex_Click()
        HTMLHelp.OpenIndex Me .HelpFile, Me .hwnd
    End Sub

Do the same with your database

As the demo indicates, there are basically four ways to do the help:

  1. F1 support: see Set Help file and contextId - this behavior should automatically work after you run the Help Generator add-in your Access database.
    F1 in MS Access 2003 only shows the topic page, not the navigation pane. As a workaround you can add a [Help] button to each form - see 2. 
  2. HTML Help (CHM) from a button on your form
  3. HTML Help (CHM) from a button -TOC - index - search
  4. Browser Based Help from a button on your form
Activating help from your application