Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make a wordmailing

Status
Not open for further replies.

GK22

Programmer
Jan 22, 2002
35
NL
I have to make an mailingapplication on my database.
with a query I select the names. Then i have to transport this to MSword, somebody who have code for me to make this or a place where I can find the code?
tnx in advance ,
gerard
 
Hi GK22,
Does this need to be done within Access? If you're referring to postal mailing and not emailing, it seems this would most easily be done through Word's Mail Merge.

If, instead, you're referring to automatically sending an email to each of the people in the query, then you could probably use the DoCmd.SendObject action. Iterate through the query, and (if you need to send individual emails) use the SendObject action on each iteration. Otherwise, add the email addresses to a string on each iteration, separating with semicolons, and use SendObject after the iteration is over.

Here's some sample code, which is off the top of my head and therefore not even close to foolproof.. I assume for the sake of the code that the query is called "qryEmails" and the Email field is called "Email".
Code may be slightly different in Access 2000.. this is for Access 97.

Dim dbs as Database, rstEmails as Recordset
Dim strEmails as String, i as Integer

Set dbs = CurrentDb
Set rstEmails = dbs.OpenRecordset "qryEmails"

With rstEmails
If Not .BOF Then
.MoveFirst
Do Until .EOF
strEmails = IIf(strEmails = "","",strEmails & ";") & _
!
.MoveNext
Loop
End If
End With

DoCmd SendObject <whatever>,<whatever>,<whatever>,strEmails
[/b]

Hope that helps! :)
 
Thanx for reaction, this will maybe solve another of my problems ;c)), I will look to Word mail merge if it can handle my problems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top