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!!
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!!