S
sml
I have a query which is parameterized for the id of record. The id is found
on an open form and I also have a button which opens a MS Word mailmerge
document which used the parameteriezed query as its datasource.
When I open the Word document the data connection is there and the document
merges, but when I use the button on the form, the data connection is lost
when the word document is open.
How can I have a button which opens a Mail Merged Word document that keeps
its data source?
The code (found on the web) that runs the button on the form is below.
Many thanks for whatever help you can provide.
Best.
Private Sub cmdWord_Click()
On Error GoTo Err_cmdWord_Click
Dim oApp As Object
Dim doc As Object
Dim strDocName As String
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
'change path
strDocName = "P:\All Agency\FY11RFND\APPLICATION - 2011 AGENCY Competitive
Bid\NOI\NOI Confirmation of Receipt Letter.docx"
Set doc = oApp.Documents.Open(strDocName)
'Set doc = oApp.Documents.Add(strDocName)
Exit_cmdWord_Click:
Exit Sub
Err_cmdWord_Click:
MsgBox Err.Description
Resume Exit_cmdWord_Click
End Sub
on an open form and I also have a button which opens a MS Word mailmerge
document which used the parameteriezed query as its datasource.
When I open the Word document the data connection is there and the document
merges, but when I use the button on the form, the data connection is lost
when the word document is open.
How can I have a button which opens a Mail Merged Word document that keeps
its data source?
The code (found on the web) that runs the button on the form is below.
Many thanks for whatever help you can provide.
Best.
Private Sub cmdWord_Click()
On Error GoTo Err_cmdWord_Click
Dim oApp As Object
Dim doc As Object
Dim strDocName As String
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
'change path
strDocName = "P:\All Agency\FY11RFND\APPLICATION - 2011 AGENCY Competitive
Bid\NOI\NOI Confirmation of Receipt Letter.docx"
Set doc = oApp.Documents.Open(strDocName)
'Set doc = oApp.Documents.Add(strDocName)
Exit_cmdWord_Click:
Exit Sub
Err_cmdWord_Click:
MsgBox Err.Description
Resume Exit_cmdWord_Click
End Sub