Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word was unable to open data source.

Status
Not open for further replies.

striker73

MIS
Jun 7, 2001
376
US
I am having difficulty applying a filter to a query. I have a form with options for the user to filter the results of a query. With these results, I am doing a mail merge with Word so the user can create a letter, envelopes or labels. I have a statement that says:

objWord.MailMerge.OpenDataSource Name:"c:\windows\desktop\myfolder\mydb.mdb", LinkToSource:=True, Connection:="QUERY qrySalesHistory", SQLStatement:=SQL_Statement

This just sets the datasource for the document I want to mail merge to the right query and applies a SQL Statement.

When my SQL statement is:

SELECT * FROM [qrySalesHistory] Where [PositionDescription] = "Purchasing"

I get an error saying that Word was unable to open the data source. The only way I can get it to work is if I use a numeric filter (ex: SELECT * FROM [qrySalesHistory] Where [SumOfAmount] < 20000)

Is there something wrong with my syntax? I tried it with single quotes around Purchasing, but that didn't seem to work either. Any ideas? Sorry this sounds so complex!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top