Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Mail-merge The Current Record, Office 2000

$
0
0
I hope someone can help; furthermore, please be aware that my knowledge of the correct terminology may not be 100% accurate but I do hope that you will afford me some understanding because of that.

I have created some code (linked to a command button on a form ("Reservations2")) which opens a word document (with mergefields) and then performs the intended mail merge: the code is below.

However, I am in need of some help please with enabling the merge to take place only on the open record of the form; ie, if I am looking at record 23 of "Reservations2" and I press the command button, it merges only the data from record 23.

I've set a criteria in the query (see attachment) to be:

[forms]![Reservations2]![Booking Reference]

...and this successfully brings up the query (in Datasheet View) with the data from the open record in the form.

However, when I click on the command button on my form, to perform the mail merge, it brings up a prompt box asking "Enter Parameter Value" for [forms]![Reservations2]![Booking Reference].

When I click OK on that, it also says that it couldn't merge the main document with the data source as the fields were empty...even though I know the query (in Datasheet view) is showing the data I need to merge.

I have searched various forums and googled for 3 whole days this week to try and find the solution/s but to no avail; in addition, I do appreciate that many members may wish to suggest the use of a report instead of mail merge; however, I most definitely want to use mail merge as I need to edit the merged document which a report will not afford.

One website (Click Here) suggested that "The only drawback to this solution is that if the Order form is not currently loaded and you run the query above, the following window will appear." and I wondered if that might be helpful; however, I know the form is loaded (well, it's open...is that the same thing ?) as that "feeds" the query.

Can anyone figure out what is happening please ?

Many thanks

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("H:\enjoy120210\CorrespondenceLetters\Ma ilMerge\BrksDednsEM.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Reservations.
objWord.MailMerge.OpenDataSource _
Name:="H:\enjoy120210\Reservations.mdb", _
LinkToSource:=True, _
Connection:="QUERY MasterDataSource", _
SQLStatement:="SELECT * FROM [MasterDataSource]"
'Execute the mail merge.
objWord.MailMerge.Execute
' Close BrksDednsEM.doc
Word.Documents("BrksDednsEM.doc").Close (Word.WdSaveOptions.wdSaveChanges)

End Function

Attached Images
File Type: jpg QueryDesignView.JPG (117.2 KB)

Viewing all articles
Browse latest Browse all 13329

Trending Articles