VB Code:
Function PrintDocument(Klant As Long, opdracht As Long)
Dim str As String
Dim doc As Object
Dim textdoc As Object
Dim wrdrange As Object
Dim adors As ADODB.Recordset
Dim naam As String
Dim vnaam As String
Set wd = CreateObject("Word.Application")
wd.Visible = False
Set doc = wd.Documents.Add("c:/program files/vbase/data/documents/dagboek.dot")
Set adors = New ADODB.Recordset
With adors
.Open "select naam, voornaam from klant where id=" & Klant, adocn, adOpenDynamic, adLockOptimistic
If Not .EOF And Not .BOF Then
doc.FormFields("Firstname").Range = " " & !voornaam
doc.FormFields("Lastname").Range = " " & !naam
End If
.Close
End With
Set adors = Nothing