My problem :
I have 2 queries based upon 1 table.
Then i have 2 word templates.
Each query fills one template.
The first query allways contains one record.
The second query may contain multiple records
in that case all the records of the 2nd query need to fill
as many times as there are records the same template.
When completed, how can i merge all these templates into 1 word.doc ?
Probably easy answer, but i'm stuck on it.
This is the code i allready have :
DoCmd.Echo False 'switch echo off so query is not displayed
DoCmd.OpenQuery "Qry Mail Merge", acNormal, acEdit 'open the query to get data
DoCmd.Close acQuery, "Qry Mail Merge", acSaveNo 'close query
DoCmd.Echo True 'switch echo back on
Dim strSite As String
strSite = DLookup("[SITE]", "Qry Mail Merge")
strHoofdID = DLookup("[HOOFDVESTIGINGID]", "Qry Mail Merge")
If IsNull(strHoofdID) Then
strHoofdID = "single site"
End If
'Niet afdrukken vanuit een nevensite
If strSite = 3 Then
MsgBox ("Dit is een nevensite! Maak offerte vanuit
Hoofdsite : " & strHoofdID)
Exit Sub
End If
'Stel vast of er nevensites zijn en vraag data op
If strSite = 2 Then
DoCmd.Echo False
DoCmd.OpenQuery "Qry Mail Merge Multi", acNormal, acEdit
DoCmd.Close acQuery, "Qry Mail Merge Multi", acSaveNo
DoCmd.Echo True
End If
'Open Word Merge document
Dim retval As Variant
Dim DocName As String
DocName = "C:\offerte\Basis verkoopsovereenkomst_B2BDP.doc"
'Note full path to Word including Drive and folder
retval = Shell("C:\Program Files\Microsoft Office\Office10\WinWord.exe " & DocName, vbNormalFocus)
I have 2 queries based upon 1 table.
Then i have 2 word templates.
Each query fills one template.
The first query allways contains one record.
The second query may contain multiple records
in that case all the records of the 2nd query need to fill
as many times as there are records the same template.
When completed, how can i merge all these templates into 1 word.doc ?
Probably easy answer, but i'm stuck on it.
This is the code i allready have :
DoCmd.Echo False 'switch echo off so query is not displayed
DoCmd.OpenQuery "Qry Mail Merge", acNormal, acEdit 'open the query to get data
DoCmd.Close acQuery, "Qry Mail Merge", acSaveNo 'close query
DoCmd.Echo True 'switch echo back on
Dim strSite As String
strSite = DLookup("[SITE]", "Qry Mail Merge")
strHoofdID = DLookup("[HOOFDVESTIGINGID]", "Qry Mail Merge")
If IsNull(strHoofdID) Then
strHoofdID = "single site"
End If
'Niet afdrukken vanuit een nevensite
If strSite = 3 Then
MsgBox ("Dit is een nevensite! Maak offerte vanuit
Hoofdsite : " & strHoofdID)
Exit Sub
End If
'Stel vast of er nevensites zijn en vraag data op
If strSite = 2 Then
DoCmd.Echo False
DoCmd.OpenQuery "Qry Mail Merge Multi", acNormal, acEdit
DoCmd.Close acQuery, "Qry Mail Merge Multi", acSaveNo
DoCmd.Echo True
End If
'Open Word Merge document
Dim retval As Variant
Dim DocName As String
DocName = "C:\offerte\Basis verkoopsovereenkomst_B2BDP.doc"
'Note full path to Word including Drive and folder
retval = Shell("C:\Program Files\Microsoft Office\Office10\WinWord.exe " & DocName, vbNormalFocus)