Can't open Help file when on subform

J

John G

Using Access 2003 on Windows XP.
I converted a .hlp help file to .chm and now I'm calling it with the code
shown below. This code works fine when the focus is on a main form or a form
with no subforms, but throws runtime error "2455" when the focus is on a
control in a subform which is within the main form. Isn't 'curForm' still the
main form? Isn't a subform seen as a control of the main form? How do I edit
the code so the help file will open when the focus is on a control of the
subform and yet still functions when the focus is on the main form? All
controls of the main and subform have contextIDs.
Thanks in advance.

Runtime Error "2455".....
You have entered an expression that has an invalid reference to the property
HelpcontextID

Public Function HelpEntry()
'Identify the name of the Help file and a possible context-id.
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

'As a default, specify a generic Help file and context-id. Note that
'the location of your file may be different.
FormHelpFile = "C:\OGG Help.chm"
FormHelpId = 9999

'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
*****Code breaks here********
If curForm.ActiveControl.Properties("HelpcontextId") > 0 Then
FormHelpId = curForm.ActiveControl.Properties("HelpcontextId")
End If
End If

'Call the function to start the Help file, passing it the name of the
'Help file and context-id.
Show_Help FormHelpFile, FormHelpId
End Function
 

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