Opening a Microsoft Word Document for a specific record


You have a form that displays client’s details so that an end-user can modify any of these clients details, and save the updates. Also on this form is a button that says "notes", which, in theory, when you click o the button, opens up a Word document file with the client's notes.

These notes are linked to the client's name i.e 'Freddy Jones' client has "freddy jones.doc" document associated.

One possible solution below:

Add the following code to the on click event for the command button:

Private Sub Command29_Click()

On Error GoTo Err_Command29_Click

Dim oApp As Object

Dim strDocName As String strDocName = "C:PathToDoc" & Me!ClientName & ".doc"

Set oApp = CreateObject("Word.Application")

oApp.Visible = True

oApp.Documents.Open strDocName


Exit Sub


MsgBox err.Description

Resume Exit_Command29_Click End Sub