R
Ray Todd Jr
Could someone please look at this code and tell me what I am missing,
please? The problem that is occuring is I am given an error (5922)
that states "Word was unable to open the data source"
As an overview, I have a form where you can put the criteria to select
the data you want to print the forms by, the form has runreport button
witht he following code. When I click on the button, I get the above
mentioned error.
If I remove the long sql statement referring to the form, everything
works fine, but I am not able to 'filter' the data that I need to
print.
Any suggestions as to what I am doing wrong?
Thanks,
Ray.
Private Sub RunReport_Click()
Dim objWord As Word.Document
Set objWord = GetObject("e:\SUMMONSFORM.DOC", "Word.Document")
'Make Word Visible
objWord.Application.Visible = True
'Set Merge Data Source
objWord.MailMerge.OpenDataSource Name:="E:\CityTaxSaleV63.mdb", _
LinktoSource:=True, _
Connection:="QUERY qryOWNERCODEFENDANTsummonsmergedata", _
SQLStatement:="SELECT * FROM qryOWNERCODEFENDANTsummonsmergedata WHER
[taTAXSALESTATUS].[TaxSaleStatus]=forms!fmOWNERCODEFENDANTsummonsmergedata!TaxSaleStatus
AN
[taCOURTDATA].[TaxSaleNumber]=forms!fmOWNERCODEFENDANTsummonsmergedata!TaxSaleNumber"
'Execute the MailMerge
objWord.MailMerge.Execute
End Sub
please? The problem that is occuring is I am given an error (5922)
that states "Word was unable to open the data source"
As an overview, I have a form where you can put the criteria to select
the data you want to print the forms by, the form has runreport button
witht he following code. When I click on the button, I get the above
mentioned error.
If I remove the long sql statement referring to the form, everything
works fine, but I am not able to 'filter' the data that I need to
print.
Any suggestions as to what I am doing wrong?
Thanks,
Ray.
Private Sub RunReport_Click()
Dim objWord As Word.Document
Set objWord = GetObject("e:\SUMMONSFORM.DOC", "Word.Document")
'Make Word Visible
objWord.Application.Visible = True
'Set Merge Data Source
objWord.MailMerge.OpenDataSource Name:="E:\CityTaxSaleV63.mdb", _
LinktoSource:=True, _
Connection:="QUERY qryOWNERCODEFENDANTsummonsmergedata", _
SQLStatement:="SELECT * FROM qryOWNERCODEFENDANTsummonsmergedata WHER
[taTAXSALESTATUS].[TaxSaleStatus]=forms!fmOWNERCODEFENDANTsummonsmergedata!TaxSaleStatus
AN
[taCOURTDATA].[TaxSaleNumber]=forms!fmOWNERCODEFENDANTsummonsmergedata!TaxSaleNumber"
'Execute the MailMerge
objWord.MailMerge.Execute
End Sub