My database A.mdb has a help file A.hlp which I prepared using Help Workshop 4.03. I called the help file using WinHelp() from a routine ShowHelpAPI() which I extracted from NorthWind.mdb, as attached at the end of the post.
The document said that A.mdb and A.hlp must reside in the same folder, which they are. Everything works as expected until I moved A.mdb and A.hlp together to a different folder. When I tried using Help, I got the error message
“Cannot find the A.hlp file. Do you want to try to find this file yourself?”
I tried by hard-coding the full path of my new folder into the code
strHelpFile = “(Actual full path and name of A.hlp)”
It works when I called ShowHelpAPI() from the menu, but when I pressed F1 key, again the same error message appeared.
My questions are:
(a) How do we make A.mdb to look for A.hlp in its own folder, so that it also works when F1 key is pressed?
( I checked the codes in the original ShowHelpAPI(), there is no telling the program that my help file name is A.Hlp, but in stepping into the codes,
strHelpFile = .HelpFile
did show the name of “A.Hlp>Mak” without the full path. How would the program know that?
Thanks.
———————————————————-
Function ShowHelpAPI() As Boolean
Dim hWnd 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.
‘ Reset Err and test for Report object.
Err = 0
Set obj = Screen.ActiveReport
If Err = 2476 Then
‘ Current object is not a form or a report; show Overview topic.
strHelpFile = “A.hlp>Mak”
lngContext = 100
lngRetVal = WinHelp(hWndAccessApp, strHelpFile, conHelpContext, lngContext)
ShowHelpAPI = True
Exit Function
End If
End If
With obj
hWnd = .hWnd
strHelpFile = .HelpFile
lngContext = .HelpContextId
End With
lngRetVal = WinHelp(hWnd, strHelpFile, conHelpContext, lngContext)
ShowHelpAPI = True
End Function