mailmerge with query

M

Marcel van Gessel

Hello, I try to create an autoopen macro wich starts from a Word 2007
document and links a query from an Access database. This query needs a
variable criteria.
It is not possible to create a parameter-query because Word does not see
this kind of query's.
So I dissided to use an inputbox for the filling of the criteria. However
the macro stops at the following rule:
..QueryString = "select * from `certificaat` where `modulecode` = `strcode`"
In this rule `certificaat` is the name of the query `modulecode` is the name
of the selectionfield and `strcode` is the name of the variable which has
been filled earlier with the inputbox.
When I replace the variabele `strcode` with the content of the criteria
(f.i. "wv") then the mailmerge is successfull, but when I use the name of the
variable (strcode) from the inputbox then it returns the errorcode 4198.
I already tried everything: yes or no brackets, apostrofs .........
Who can help me?
 
D

Doug Robbins - Word MVP

I believe that your query string should be:

..QueryString = "select * from `certificaat` where `modulecode` = '" &
strcode & "`"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top