More Detail on F1 - Access .chm Problem

G

Gordon Jones

I have posted questions the past few days about my inability to get the F1
key to call out my help file (CBW5Help.chm). Operating on instructions from
Microsoft Knowledge Base Q271390, I followed their instructions to create a
module and macro. I couldn't get the F1 to work, but did see how to use the
module to enable a "Help Button" to invoke the fixing function "HelpEntry()".


I posted a new release with my program’s update yesterday which included my
new CBW5Help.chm, and asked for feedback on it. The very first one, using
XP/Access 2002 said neither the F1 nor the help button worked. I’ve been at
this since about 0230 this morning, and have tried it on three machines using
Access 2002 and 2003.

The code you distributed from Microsoft does several things:

· It defines 3 functions.

o Public Function HelpEntry() selects either your own hard coded
default FormHelpFile and FormHelpID or those belonging to the
(curForm.ActiveControl.Properties("HelpcontextId"))

o Public Function Show_Help(HelpFileName As String, MycontextID As
Long) gets the file name and ID from HelpEntry. It prepares a request to the
third function, based on whether the ID it receives from HelpEntry is zero or
not. In my case, there is never a zero, so calls on the third function as
follows:
HtmlHelp(Application.hWndAccessApp, HelpFileName, HH_HELP_CONTEXT,
MycontextID) . This function returns a long integer giving the results of the
running of HtmlHelp, stored in variable “hwindHelpâ€.
In my case the 3 input variables are “CBW5Help.chmâ€, 15, and 10045.

o The third is: Declare Function HtmlHelp Lib "hhctrl.ocx" Alias
"HtmlHelpA" _

(ByVal hwndCaller As Long, ByVal pszFile As String, _

ByVal uCommand As Long, ByVal dwData As Long) As Long

This function is obviously called from within Access. I can only surmise
that it does the heavy lifting after it gets the HH type data from HelpEntry
and Show_Help.

· It also contains instructions to create a Macro named AutoKeys,
and defines the {F1} key as one that executes code and the code is contained
in the function HelpEntry().

When I execute my program on my development Vista machine using Access 2002,
and I press the Help Button that calls HelpEntry(), I get the return
hwindHelp value set at 920344, and the help file opens to the proper place.

When I execute it on a laptop running Vista, using either Access 2002 or
Access 2003, I press the Help Button that calls HelpEntry(), I get the return
hwindHelp value set at 0, and the help file does not open.

When I execute it on an older desktop XP machine, using Access 2002, I press
the Help Button that calls HelpEntry(), I get the return hwindHelp value set
at 0, and the help file does not open.

I am at the limit of what I can do to tie this down. I have repackaged my
program to include a Shortcut directly to the CBW5Help.chm. It seems to open
in all my environments. I am also trying to package a .pdf file just in case
the .chm doesn’t work in users’ environments.

Can anyone help me understand where and why the F1 isn't working, and why
the Help Button doesn't work except on my development machine?

I'd certainly appreciate any leads, and can furnish anyone with the source
codes if that would help.
 
G

Gordon Jones

Thanks a lot, Doug. I have scanned the 4 pages and it tells me two things --
the problem has been around for at least 6 years, and a guy with a lot more
smarts than I have spent a lot of time examining the same problem. Sort of.
You seem to have been involved with getting the path to the .mdb. The code I
referenced handles that o.k. And I am willing to settle for the use of a
"Help Button" to summon the context help, and it works on my development
machine, but apparently nowhere else that I have been able to identify.

My Dev machine is about 6 months older than the laptop -- both Vistas -- and
I have tried to keep the Access part of them at the same level. But if the
Development machine can pull the help topics from the CBW5Help.chm, I don't
see why the Laptop can't.

Anyhow, I will play around with the code to open the HTML Help file to a
topic and see if that works any better or worse. If anything else occurs to
you, please let me know.
 
G

Gordon Jones

Doug, I have taken the code from the David Liske article and substituted it
for several lines of code and functions in the KB article code. The
following is what it looks like now:

Public Function HelpEntry()
Dim FormHelpId As Long
Dim FormHelpFile As String
Dim curForm As Form

'Set the curForm variable to the currently active form.
Set curForm = Screen.ActiveForm
'MsgInfo (curForm.Name & " is the Active Form")
HCID = curForm.HelpContextId
Beep
'As a default, specify a generic Help file and context-id. Note that the
location of your file may be different.
FormHelpFile = "CBW5Help.chm"
FormHelpId = 10001
'Check the Help file property of the form. If a Help file exists, assign
the name and context-id to the respective variables.
If curForm.HelpFile <> "" Then
FormHelpFile = curForm.HelpFile
End If

'If the Help context-id of the control is not null and greater than
zero, assign the value to the variable.
If Not IsNull(curForm.ActiveControl.Properties("HelpcontextId")) Then
If curForm.ActiveControl.Properties("HelpcontextId") > 0 Then
FormHelpId = curForm.ActiveControl.Properties("HelpcontextId")
End If
End If

'force HelpContextID to always be that of the Current Form
FormHelpId = HCID

'HTMLHelpStdCall 0, FormHelpFile, HH_HELP_CONTEXT, FormHelpId 'comment
out to try next line
HTMLHelpStdCall 0, "CBW5Help.chm", HH_HELP_CONTEXT, FormHelpId 'Trying
the HelpEntry1 code below,


'Call the function to start the Help file, passing it the name of the
Help file and context-id.
'Show_Help FormHelpFile, FormHelpId ' COmment out to use direct call
from HelpEntry1
End Function

I hope when this it transmogrified into a reply, that the code is legible.
The key change is toward the bottom, where the line HTMLHelpStdCall is used.
When I put that in my development machine, it works like a fine clock.
Either the F1 key or the Help button which calls HelpEntry() bring the
correct topic up swiftly. However, when I copy the program over onto another
machine, neither the F1 nor the Help Button works, but if I do Alt+F1, it
will bring up the Microsoft Access help window (empty). I put a stop on both
machines, and they were both giving the same arguments to the
HTMLHelpStdCall. One funny thing, though. On both machines, after they End
Function, they re-execute the code, coming back to the stops in the same
place. On my development machine, if I close the help topic, it brings it
back up on the second trip through; the other machine doesn't. So it appears
that the F1 is being fielded twice, once inside and once outside of Access.

On the development machine, I use only Access 2002. On the second machine I
use both 2002 and 2003, and get the same results.

I don't know anything about the F1CDHelp system, or how it works internally,
but do you have any ideas why I should get such different results on two
(Vista) machines that should be almost identical?
 
D

Douglas J. Steele

It's been too many years since I've played with that code, I'm afraid.

Does David have any contact information? There's a newsgroup
microsoft.public.helpauthoring that may be of use. Not sure whether you can
get to it through the web interface you're using, though, but you could try
through Google Groups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top