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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail Merge from an access report.

Status
Not open for further replies.

flick371371

Programmer
Jun 15, 2010
3
GB
Hi Guys,

I have gone back to basics with an access DB. Its really simple as its a freelance job. I have one simple form with im using as a gui. From this form there are four simple searches (postcode, pcode, area, school name). Each search runs a different query in the background which produces one of four reports. I need to find a way to mail merge the results of the report (or the query) into a .doc

Ideally I want this to be a one click button on the bottom of each report.

I tried using someone script (which i doctored) and also the automatic wizard which just kept falling over.

I could do with an answer ASAP as im already past the deadline

I can send a copy of the DB to anyone if that will help as its only small.
 
You can't put a button anywhere on a report and expect to apply any functionality. Mail merging has nothing to do with a report. I typically use code like:
Code:
DoCmd.TransferText acExportDelim, , strQuery, strFile, true
Dim oApp As Object 'New Word.Application
Dim oDoc As Object 'New Word.Document
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
Set oDoc = oApp.Documents.Add
[green]'oApp.Documents.Add[/green]
oDoc.MailMerge.OPENDATASOURCE Name:=strFile, Format:=0, ConfirmConversions:=True
[green]'oApp.MailMerge.DataSource = Me.txtFileName[/green]
MsgBox "You can now switch applications to Word to create your merge document", vbOKOnly + vbInformation, "Merge Ready"

Duane
Hook'D on Access
MS Access MVP
 
Do you mean create a VB Module with that particular code?

The last time I tried that it told me that my sql string was too long. Is that because I wrote the sql queries manually??
 
In this particular code, I had previously modified the SQL property of a saved querydef. strQuery stores the name of the query.

I had this code running in the On Click of a button on a form.

Duane
Hook'D on Access
MS Access MVP
 
Your a legend.

Ill give this a go tonight, so tomorrow i mght be screaming for help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top