I've been working on this mail merge for a while and can't get it right (Office XP). I want the document to merge from a query that is already in the database and then to be filtered to only the record that is showing on the form. The code I've found in other threads is all similar but doesn't quite work for me. Here is some of my code:
Dim objWord As Word.Document
Set objWord = GetObject("C:\COEWork\Letter_TBV.doc"
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource
CurrentProject.Path, , , , True, , , , , , , "QUERY
qryStudentMinor", "Select * from [qryStudentMinor]
WHERE [id]='" & Me!txtID & "'"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
I've used the actual DB path instead of CurrentProject.Path and that hasn't worked either. I've tried my word document with the data source already set to the DB and with it empty and just the merge fields in the body. When I press the form button, Word opens and I get a "Confirm data source" dialog box and I don't know why. Do I need to set up an actual ODBC data source? Do I need to change my code? The word document? Please help! Thanks.
Dim objWord As Word.Document
Set objWord = GetObject("C:\COEWork\Letter_TBV.doc"
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource
CurrentProject.Path, , , , True, , , , , , , "QUERY
qryStudentMinor", "Select * from [qryStudentMinor]
WHERE [id]='" & Me!txtID & "'"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
I've used the actual DB path instead of CurrentProject.Path and that hasn't worked either. I've tried my word document with the data source already set to the DB and with it empty and just the merge fields in the body. When I press the form button, Word opens and I get a "Confirm data source" dialog box and I don't know why. Do I need to set up an actual ODBC data source? Do I need to change my code? The word document? Please help! Thanks.