MS Access: HTML Help (CHM) from a button -TOC - index - search

The most important ways to open help are F1 and a Help button that open content sensitive help. You can add additional ways to call the Help file:

You can import the required module from the Access demo database which you can download from here:

Adding code to implement additional Help features

  1. Import the following modules and classes in your database
  2. Open the form you want to add the help button to in Design mode
  3. Add a [Help] button to a form
  4. Set the button property name to 'cmdHelp' (or something like that - give it meaningul name)
  5. Right-click on the newly created button
  6. Select 'Build Event'
  7. Select Code Builder and click OK
  8. The VB editor opens with Private Sub 'cmdHelp_Click() ... End Sub inserted
  9. Insert code so that the result looks like in the sections below, depending on required behavior. 

Open Help on Table Of Contents tab

Private Sub cmdHelpTOC_Click()
    HTMLHelp.OpenTOC Me .HelpFile, Me .hwnd
End Sub

Open Help on Index tab

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

Open Help on Search tab

Private Sub cmdSearch_Click()
    HTMLHelp.OpenSearch  Me .HelpFile, Me .hwnd
End Sub

Open Help using a Topic page url and optionally bookmark

Private   Sub  cmdBookmark_Click()
Dim  strHtmlFileName  As   String
Dim  strHtmlFileBookmark  As   String
Dim  strBookmark  As   String
    strHtmlFileName = "accHelpDemo_Form_frmCustomers_CustomHelp.htm"
    strHtmlFileBookmark = "frmCustomers_CustomHelp_Phone"
    strBookmark = strHtmlFileName
     If   Len (strHtmlFileBookmark) > 0  Then
       strBookmark = strBookmark & "#" & strHtmlFileBookmark
     End   If
    HTMLHelp.OpenTopic strBookmark,  Me .HelpFile
End Sub 

Open Help using Help Context Id

Private Sub cmdContextId_Click()
Dim lHelpContextId As Long
    lHelpContextId = Screen.PreviousControl.HelpContextId
    If lHelpContextId = 0 Then
        lHelpContextId = Screen.ActiveForm.HelpContextId
    End If
    HTMLHelp.OpenContext lHelpContextId, Me.HelpFile
End Sub
MS Access: starting help from code