I'm a newbie looking for advice. Anyone have any helpful suggestions for vb code to program a command button on click event to get data from a form to a mail merge in Word? It's not just labels I'm creating, but rather a letter related to an event, using fields on the form that are specific to the event shown. I saw a similar thread that used an IF statement, choosing 1 of 2 letters. I tried to modify that below. Any advice appreciated!
Private Sub cmdListingLetter_Click()
On Error GoTo Err_cmdListingLetter_Click
Dim objWord As Word.Document
Date = Now()
Set objWord = GetObject("c:\Path to my document here", "Word.Document"
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource_Name = "c:\Path to my database file as data source"
LinkToSource = True
Connection = "qryListingLetterMerge"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
End Sub
Private Sub cmdListingLetter_Click()
On Error GoTo Err_cmdListingLetter_Click
Dim objWord As Word.Document
Date = Now()
Set objWord = GetObject("c:\Path to my document here", "Word.Document"
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource_Name = "c:\Path to my database file as data source"
LinkToSource = True
Connection = "qryListingLetterMerge"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
End Sub