• How would I open a corresponding Word document (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » How would I open a corresponding Word document (Access 2000)

    Author
    Topic
    #416928

    I have a form that has a button on it that opens Word. But I want it to open a certain document in Word depending on what record I am in. For example, I go into record 1 and the form has a button to open a file called “Problem1.doc”. If I go into record 2 and click the button it should bring up file “Problem2.doc”. So the button opens up the document with the corresponding number.

    The field name for the record number is [ProblemNum]. The files are all called “Problem[ProblemNum].doc”. Is this possible to do? Here’s the code for my button so far.

    Private Sub cmdDetail_Click()
    On Error GoTo Err_cmdDetail_Click

    Dim oApp As Object

    Set oApp = CreateObject(“Word.Application”)
    oApp.Visible = True

    Exit_cmdDetail_Click:
    Exit Sub

    Err_cmdDetail_Click:
    MsgBox Err.Description
    Resume Exit_cmdDetail_Click

    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #933886

      You don’t need to create a Word.Application object. Try this:

      Private Sub cmdDetail_Click()
      On Error GoTo Err_cmdDetail_Click
      ‘ Substitute the appropriate path
      Application.FollowHyperlink “C:DocumentFolderProblem” & Me.[ProblemNum] & “.doc”

      Exit_cmdDetail_Click:
      Exit Sub

      Err_cmdDetail_Click:
      MsgBox Err.Description
      Resume Exit_cmdDetail_Click
      End Sub

    Viewing 0 reply threads
    Reply To: How would I open a corresponding Word document (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: