MS Access: HTML Help (CHM) from a button on your form

When you have created a help file and set the Help File and Help Context Id, you have the Help available via F1. If you want to promote the use of help, it is a good practice to also add a [Help] button. The approach described here allows you to implement a Help button with a minimum amount of effort (and code) on your forms.

You can import the required module from the Access demo database which you can download from here:
  1. Import the following modules and classes in your database: CFormHtmlHelpHandler, CHTMLHelp and basHtmlHelp.
  2. Open the form you want to add the help button to in Design mode
  3. Make the Property Sheet visible
  4. Right-click on the form
  5. Select Properties
  6. Add Form_Open event code to the form to keep the relevant contextid in a variable
  7. In the Properties window combo box at the top, select Form - this makes it the object the properties are editable from
  8. Select the Event tab
  9. Put the cursor in the 'On Open' row - two buttons appear
  10. Click the [...] button - a dialog appears showing your build options
  11. Select Code Builder and click OK
    The VB editor opens with Private Sub Form_Open... End Sub inserted
    1. Insert code so that the result looks like this
      Private Sub Form_Open(Cancel  As Integer )
          HTMLHelp.InitFormHelpHandler  Me , Me !cmdHelp
      End Sub
You don't have to set the button's On Click event. This is handled by the Init procedure of the CFormHtmlHelpHandler class

    12.    Add a [Help] button to a form 
    13.    Set the button property name to 'cmdHelp'

Now, assuming your form has valid properties set for Help File and Help Context Id and a matching help file, clicking the button, after switching to Form View, will open the corresponding page in the help file.

Your  Help File and Help Context Id - and Map and Alias files, topic files and the rest - are automatically set / created when you use the Help Generator add-in for MS Access
MS Access: starting help from code