Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004

    Unanswered: Assigning help file in access

    I need to assign help file in access app. I want to open chm file by pressing f1 . I assigned context sensitive help but I need it when no form has focus. Thanx in advance

  2. #2
    Join Date
    Mar 2004
    Are you wanting to display a custom help file whenever the database window is open?

  3. #3
    Join Date
    Mar 2004

    Assigning a help topic in Access

    If you want a custom help file to be displayed whenever a form or report does not have the focus, you will have to do several things.


    In the declarations sections of a new or existing module (mine is called CustomFunctions) paste the following code:

    Private Declare Function WinHelp Lib "user32" Alias "WinHelpA" _
    (ByVal hWnd As Long, ByVal lpHelpFile As String, _
    ByVal wCommand As Long, ByVal dwData As Long) As Long


    In this same module, paste the following code: (This code is modified from the Access 2.0 Solutions database)

    Function ShowHelpAPI() As Boolean

    ' This function uses the WinHelp API function so that context sensitive help
    ' is displayed regardless of the current state of the object.
    ' Make sure that the Help file is in the same directory as the database.

    Dim lnghWnd As Long, strHelpFile As String, lngContext As Long
    Dim lngRetVal As Long, obj As Object

    On Error Resume Next
    Const conHelpContext = &H1
    Set obj = Screen.ActiveForm

    If Err = 2475 Then ' Active object is not a form.
    Err = 0 ' Reset Err and test for Report object.
    Set obj = Screen.ActiveReport
    If Err = 2476 Then ' Current object is not a form or a report.
    ShowHelpAPI = False
    Err = 0
    GoTo ShowHelp
    End If
    End If

    With obj
    ' Get the current object's hWnd, HelpFile, and HelpContextID properties.
    lnghWnd = .hWnd
    strHelpFile = .HelpFile
    lngContext = .HelpContextId
    End With

    lngRetVal = WinHelp(lnghWnd, strHelpFile, conHelpContext, lngContext)
    ShowHelpAPI = True
    Exit Function

    ' A form or report was not active so show Help File
    lnghWnd = &H1
    strHelpFile = "MyHelpFile.hlp"
    lngContext = &H1

    lngRetVal = WinHelp(lnghWnd, strHelpFile, conHelpContext, lngContext)
    ShowHelpAPI = True
    Exit Function

    End Function


    Create a macro and name it AutoKeys. This is the macro used whenever the database starts to reassign the default key assignment.

    This macro is a Macro Group
    First macro name is: {F1}
    Action is "RunCode"
    Function Name is: ShowHelpAPI() 'or whatever name you give to above function.


    This will reset the default F1 key to whatever help topic you have created for your database. If you are still in the design phase, include this macro in only the database the users will have access to, otherwise you will not have access to built-in Access help.

  4. #4
    Join Date
    Mar 2004
    Thanx Toliver You have helped me a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts