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