A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Mail merge to Word from Access 2000



 
 
Thread Tools Display Modes
  #1  
Old August 4th, 2004, 11:14 AM
Anthony
external usenet poster
 
Posts: n/a
Default Mail merge to Word from Access 2000

Hi

I am trying to create code for a command button on a MS
Access 2000 form,
which, when clicked, uses mail merge to create a Word
document for the
active record only.

The code I am using (see below) is contained within a
Module in Access. It
successfully creates merges Word docs for ALL of the
records, but I want to
create a single document for the active record only.

*****************start code*********************
Function MergeIt()

Dim objWord As Word.Document
Set objWord = GetObject("C:\My
Doc.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind
database.
objWord.MailMerge.OpenDataSource _
Name:="C:\My Database File.mdb", _
LinkToSource:=True, _
Connection:="QUERY Patient Details Query", _
SQLStatement:="SELECT * FROM [Patient Details Query]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function

****************end code************************

I tried inserting a WHERE statement within the
SQLStatement

ie. SQLStatement:="SELECT * FROM [Patient Details Query]"
& _
"WHERE [PatientID]= Me!PatientID"

but this didn't work.

Any ideas for a WHERE statement that will merge only a
single record into
Word? If not, is there perhaps another approach?

Thanks in Advance
Anthony




  #2  
Old August 4th, 2004, 12:35 PM
Arvin Meyer
external usenet poster
 
Posts: n/a
Default Mail merge to Word from Access 2000

I have some code which uses Bookmarks in Word:

http://www.datastrat.com/Code/WordMerge.txt

I believe Albert Kallal also has some on his site.

http://www.attcanada.net/~kallal.msn.../msaccess.html
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

"Anthony" wrote in message
...
Hi

I am trying to create code for a command button on a MS
Access 2000 form,
which, when clicked, uses mail merge to create a Word
document for the
active record only.

The code I am using (see below) is contained within a
Module in Access. It
successfully creates merges Word docs for ALL of the
records, but I want to
create a single document for the active record only.

*****************start code*********************
Function MergeIt()

Dim objWord As Word.Document
Set objWord = GetObject("C:\My
Doc.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind
database.
objWord.MailMerge.OpenDataSource _
Name:="C:\My Database File.mdb", _
LinkToSource:=True, _
Connection:="QUERY Patient Details Query", _
SQLStatement:="SELECT * FROM [Patient Details Query]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function

****************end code************************

I tried inserting a WHERE statement within the
SQLStatement

ie. SQLStatement:="SELECT * FROM [Patient Details Query]"
& _
"WHERE [PatientID]= Me!PatientID"

but this didn't work.

Any ideas for a WHERE statement that will merge only a
single record into
Word? If not, is there perhaps another approach?

Thanks in Advance
Anthony






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word hangs saving new document after merge to access database Sandy Mailmerge 4 May 19th, 2004 03:43 PM
mail merge w/ word and excel jmorris Mailmerge 3 May 5th, 2004 03:36 PM
Word XP Mail Merge Ch'Mekazul Mailmerge 1 May 5th, 2004 03:51 AM
Word mail merge with Excel data Peter Jamieson Mailmerge 1 April 26th, 2004 07:30 PM
Word 2003 is adding duplicate records to my mail merge Doug Robbins - Word MVP Mailmerge 0 April 24th, 2004 03:58 AM


All times are GMT +1. The time now is 01:30 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.