M
martin
I have created a button on a form to print infomation on
to a word template. Below is the shortened version of the
code. When ran, it go through to the end however it prints
out nothing onto the word document. You can get the code
to work but you have to replace the strName variable in
the SQL statement with an actual Name. Is it the case that
I can not use a variable in an SQL stsatement or have I
gone about it the wrong way???
Thanks In Advance
Martin
Dim rstPrintOut As New ADODB.Recordset
Dim AppWord As New Word.Application
Dim strName As String
strName = Me.txtCustomerName
rstWorkAllPrintOut.Open "SELECT * from
tblPolicyHolders where phName LIke 'strName'", _
CurrentProject.Connection, adOpenStatic,
adLockOptimistic
AppWord.Documents.Add "\\PC1\Temps\~Mandate.dot"
With AppWord
.ActiveDocument.ShowSpellingErrors = False
.Selection.GoTo wdGoToBookmark, Name:="bmkAddress"
.Selection.TypeText rstPrintOut!phAddress
AppWord.Visible = True
End With
to a word template. Below is the shortened version of the
code. When ran, it go through to the end however it prints
out nothing onto the word document. You can get the code
to work but you have to replace the strName variable in
the SQL statement with an actual Name. Is it the case that
I can not use a variable in an SQL stsatement or have I
gone about it the wrong way???
Thanks In Advance
Martin
Dim rstPrintOut As New ADODB.Recordset
Dim AppWord As New Word.Application
Dim strName As String
strName = Me.txtCustomerName
rstWorkAllPrintOut.Open "SELECT * from
tblPolicyHolders where phName LIke 'strName'", _
CurrentProject.Connection, adOpenStatic,
adLockOptimistic
AppWord.Documents.Add "\\PC1\Temps\~Mandate.dot"
With AppWord
.ActiveDocument.ShowSpellingErrors = False
.Selection.GoTo wdGoToBookmark, Name:="bmkAddress"
.Selection.TypeText rstPrintOut!phAddress
AppWord.Visible = True
End With