Microsoft KB Archive/100157

{|
 * width="100%"|

PRA: Help Context ID Property Does Not Work in Subform
'Article ID: Q100157

Creation Date: 16-JUN-1993

Revision Date: 19-SEP-1996' The information in this article applies to:


 * Microsoft Access version 1.0

SYMPTOMS

If you press the F1 key to invoke the Help system when the insertion point is in a subform control, Microsoft Access invokes the main form's Help file Contents window, rather than invoking the appropriate Help topic for the subform control.

CAUSE

Microsoft Access ignores the Help ContextID property of the subform control.

RESOLUTION

As a workaround for this problem, you can follow the steps below to create a custom Help function that will test to determine which control is active on a form, and then call the Microsoft Windows Help API function to invoke the appropriate Help topic for that control:

  Create the following macro and save it as AutoKeys: MacroName    Action -     {F1}          RunCode AutoKeys Actions --     RunCode Function Name: =Help("") NOTE: Substitute the correct drive, path, and filename for the Help file you want to use in the example above.   Create a module with the following sample code: NOTE: In the following sample code, an underscore (_) is used as a line-continuation character. Remove the underscore when re-creating this code in Access Basic. 

'*************************************************************  'Declarations section of the module '*************************************************************  Option Explicit

Declare Function WinHelp% Lib "User" (ByVal hwnd%, ByVal lpHelpFile$,_                                        ByVal wCmd%, ByVal dwData As   Any)

Global Const HELP_CONTEXT = &H1 Global Const HELP_CONTENTS = &H3

'*************************************************************  ' FUNCTION NAME: Help '  ' PURPOSE: '  Based on the currently active control, the Windows Help API '  function is called to invoke Help on a predefined ContextID for '  the control. If the ControlName is not represented, a  '   message appears, indicating no Help topic is available. '  If there is no active form available, the contents of the '  Help file are invoked. '  ' INPUT PARAMETERS: '  HelpFile: Path and filename of Help file to use '  ' RETURN '  None '*************************************************************  Function Help (HelpFile As String) Dim ContextID As Long Dim Ret As Integer

On Error GoTo HelpError

' Determine which control needs Help and set the ' .. appropriate ContextID for the control. Select Case Screen.ActiveControl.ControlName

'NOTE: You must customize the Case statements that follow '     for your specific control names and the ContextID to call '     for the control name.

Case "Category ID" ContextID = 1 Case "Category Name" ContextID = 1 Case "Description" ContextID = 1 Case "Product ID" ContextID = 2 Case "Product Name" ContextID = 2 Case "Unit Price" ContextID = 2 Case "Picture" ContextID = 2 Case Else MsgBox "No help for " & Screen.ActiveControl.ControlName ContextID = -1 End Select

' Call the Help file with the appropriate ContextID. If ContextID > -1 Then Ret = WinHelp(Screen.ActiveForm.hwnd, HelpFile, _                      HELP_CONTEXT, ContextID) End If

GoTo ByeHelp

HelpError: ' Display the Contents window of the Help file. Ret = WinHelp(0, HelpFile, HELP_CONTENTS, 0&) Resume ByeHelp

ByeHelp: End Function STATUS

Microsoft has confirmed this to be a problem in Microsoft Access version 1.0. This problem no longer occurs in Microsoft Access version 1.1.
 * }

-

"THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED 'AS IS' WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''

Additional reference words: 1.00

KBCategory: kbusage

KBSubcategory: FmsSubf