
MailMerge from Access 97 to Word 97, value lost
I want to MailMerge from Access 97 to Word 97, but a DialogBox ask me the
current value of the ID that I need to MailMerge. Maybe I lose the ID. Why?
Thanks.
Source code in VBA:
Private Sub Commande_MailMerge_Click()
Const DOCname = "Document_mydoc.Doc"
On Error GoTo Err_Commande_MailMerge_Click
Dim oApp As Object
Set oApp = CreateObject("Word.Application")
Set doc = oApp.documents.Open(Application.CurrentProject.Path & "\" &
DOCname)
oApp.Visible = True
Dbname = Application.CurrentDb.Name
With doc.MailMerge
.OpenDataSource Name:= _
Dbname, Connection:="QUERY R_publipostage_document"
.Destination = wdSendToNewDocument
.Execute
Exit_Commande_MailMerge_Click:
Exit Sub
Err_Commande_MailMerge_Click:
MsgBox Err.Description
Resume Exit_Commande_MailMerge_Click
End With
oApp.Quit savechanges:=False
Exit Sub
Erreur:
MsgBox Err.Description
Exit Sub
End Sub
My request :
SELECT Tb_Document.Id_document,
FROM Tb_Document
WHERE
(((Tb_Document.Id_document)=[Formulaires]![For_document]![Id_document])) ;