Knowledge Base |

# ACC: How to Call the Windows Help Search Dialog Box

Article ID: 109826

Article Last Modified on 5/6/2003

APPLIES TO

- Microsoft Access 1.0 Standard Edition
- Microsoft Access 1.1 Standard Edition
- Microsoft Access 2.0 Standard Edition

This article was previously published under Q109826

## SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.
This article describes how to call the Windows Help Search dialog box from within your Microsoft Access application using the WinHelp() and FindWindow() Windows API function calls.
This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x, or the "Building Applications" manual, Chapter 3, "Introducing Access Basic," in version 2.0.

## MORE INFORMATION

The following example demonstrates how to activate the Search dialog box with a sample Access Basic function called OpenHelpSearch(). This example uses the Microsoft Access Help file:
NOTE: In the following sample code, an underscore (_) is used as a line- continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.

1. Enter the following lines in a new module's Declarations section:

             Option Explicit
             Global Const HELP_PARTIALKEY = &H105
             Declare Function WinHelp Lib "User" (ByVal hWnd As _
                Integer, ByVal lpHelpFile As String, ByVal _
                wCommand As Integer, ByVal dwData As Any) As Integer
             Declare Function HC_FindWindow% Lib "user" Alias "FindWindow" _
                (ByVal lpClassName As Any, ByVal lpCaption As Any)

2. Create two procedures by entering the following code in the module:

              Function OpenHelpSearch ()
                Dim DummyVal$, Temp%
                DummyVal$ = ""
                Temp% = WinHelp(GetAccessHandle(),_
                   "c:\Access\msaccess.hlp", HELP_PARTIALKEY, DummyVal$)
                'For version 2.0, replace Temp% = etc with the following:
                'Temp% = WinHelp(GetAccessHandle(),_
                '   "c:\Acc2\msacc20.hlp", HELP_PARTIALKEY, DummyVal$)
             End Function

             Function GetAccessHandle ()
                GetAccessHandle = HC_FindWindow("Omain", 0&)
             End Function

3. Save the module as Search Help.
4. From the Run menu, choose Compile All.
5. Type the following in the module's Immediate window, and then press ENTER:
   `? OpenHelpSearch()`

When you call the OpenHelpSearch() function, the Windows API WinHelp() function is called. The OpenHelpSearch() function passes the current Microsoft Access handle, the name of the Help file, the command HELP_PARTIALKEY and a null string to the WinHelp() function. You are then prompted for a topic to search for. Note that you can call the OpenHelpSearch() function from any command button.

## REFERENCES

"Programming Windows: The Microsoft Guide to Writing Applications for Windows 3," Charles Petzold, Microsoft Press, 1990
"Programmer's Reference Library: Microsoft Windows 3.1 Guide to Programming Reference," Volumes 1-6, Microsoft Press, 1992

Keywords: kbhowto kbprogramming KB109826