Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine if a form or a report is currently active 1

Status
Not open for further replies.

48Highlander

Technical User
Feb 8, 2004
119
CA
I have had to go through hoops to get Access properly linked with an HTML help file. I now have all of the forms working properly when the user presses F1 to get help. However, when the user wants to get the help topic for the report, my code doesn't work.

The following code came from MS KB271390 and it is run when an autokey macro for {F1} is run.

How do I change it to detect that the active object is a report, not a form, and then retrieve the HelpContextID of the report?

Code:
Public Function HelpEntry()

    'Identify the name of the Help file and a possible context-id.
    Dim FormHelpId As Long
    Dim curForm As Form

    Dim CurrentPath As String
    CurrentPath = CurrPath()
    strHelpFile = CurrentPath & "MrHelpFile.chm"
    
    '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.

    FormHelpId = 10

    '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
        strHelpFile = 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")
        Else
            FormHelpId = curForm.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 strHelpFile, FormHelpId
    
End Function

Bill J
 
Look at Screen.Application.CurrentObjectType to find out if it is a form or report, use Screen.Application.CurrentObjectName for its name and Screen.ActiveReport instead of Screen.ActiveForm to get the reports details.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top