G
Guest
Hello:
Our goal in our little Training Team is to click a button on a One to Many
Form and either:
a. Do a Word Email Merge sending an email to every student registered in the
class
or
b. Do a Word Email Merge sending an email to one student showing every class
where he/she is registered.
I created the Access Query and the Word Email Merge and can run them
manually. From Access, I click on a form button to run the query. I then
manually open Word to the saved Email Merge letter and send the email to
every student using Word’s Mail Merge functionality. Everything works
perfectly when doing it manually.
My question is:
Can I write code that will run the Access Query from the form and then
execute the Word Email Merge directly from Access? In other words, the only
thing the user would have to do is click on a command button on the form.
Note:
Here's name of the Word File we're using in test mode and the query that we
run on the form.
MailMerge_Test_OneClass.doc
Private Sub cmdRunTestQueryForEmail_Click()
On Error GoTo Err_cmdRunTestQueryForEmail_Click
Dim vClassNo As String
Dim stDocName As String
vClassNo = Me.ClassNo
stDocName = "qryTestEmail_OneClass"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmdRunTestQueryForEmail_Click:
Exit Sub
Err_cmdRunTestQueryForEmail_Click:
MsgBox Err.Description
Resume Exit_cmdRunTestQueryForEmail_Click
End Sub
Thanks,
Robert
Our goal in our little Training Team is to click a button on a One to Many
Form and either:
a. Do a Word Email Merge sending an email to every student registered in the
class
or
b. Do a Word Email Merge sending an email to one student showing every class
where he/she is registered.
I created the Access Query and the Word Email Merge and can run them
manually. From Access, I click on a form button to run the query. I then
manually open Word to the saved Email Merge letter and send the email to
every student using Word’s Mail Merge functionality. Everything works
perfectly when doing it manually.
My question is:
Can I write code that will run the Access Query from the form and then
execute the Word Email Merge directly from Access? In other words, the only
thing the user would have to do is click on a command button on the form.
Note:
Here's name of the Word File we're using in test mode and the query that we
run on the form.
MailMerge_Test_OneClass.doc
Private Sub cmdRunTestQueryForEmail_Click()
On Error GoTo Err_cmdRunTestQueryForEmail_Click
Dim vClassNo As String
Dim stDocName As String
vClassNo = Me.ClassNo
stDocName = "qryTestEmail_OneClass"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmdRunTestQueryForEmail_Click:
Exit Sub
Err_cmdRunTestQueryForEmail_Click:
MsgBox Err.Description
Resume Exit_cmdRunTestQueryForEmail_Click
End Sub
Thanks,
Robert