View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Set a field before running query

Well...

If your user has Access on their system, and you make the connection to
Access using the old DDE method, you can connect to a parameter query in
Access which will then pop up a dialog box asking for the parameter value.
However, DDE has some drawbacks (e.g. it hasn't really been supported for
years, doesn't let Unicode date through, and complicates the user
interaction). but if you want to try it,
a. set up your query as a parameter query
b. check Word Tools|Options|General|Confirm conversion at open (in Word
2007 the option is somewhere near the bottom of Word Office Button|Word
options|Advanced)
c. go through the connection process again, select the DDE option when
offered, and select the parameter query
d. when the user opens the mail merge main document in Word, Word should
automatically start Access if it is not already running, and open the
appropriate database if it is not already open, and connect to the query.
However, when Access pops up a dialog box for the parameter, be aware that
it may appear behind the Word window and that the user may need to Alt-tab
to see it. If they don't, eventually they will probably see a message saying
that Word has failed to connect.

You could also consider using Word VBA's OpenDataSOurce method to issue the
correct SQL (e.g. prompt for the value before the merge using a Userform or
Inputline, construct the SQL, and issue it via OpenDataSource) or to EXECUTE
the parameter query and pass the parameter you want (not something I have
used "for real"), and possibly a couple of other approaches.

Peter Jamieson

"NeedHelp" wrote in message
...
Sure thing...

I have a two tables. Table1 has a filed named Year. Table2
has fields FirstName, LastName, and PaidDate. I have
a query (used by the Word document) that selects all records
from Table2 in which PaidDate is within Table1.Year.

I would like allow the user to set the Table1.Year field
and have the query refresh using that new value.

It doesn't have to be real fancy. If I have to set it up
so that the user must specify the year on opening the
Word document, that's OK. If the user makes a mistake
he has to close and reopen, that's OK.

Hope that's enough detail. Is this doable?


Peter Jamieson wrote:
Can you spell this out a bit please?

Your query returns a value (let's say it returns a value of "2" in a
column called "myvalue")

You present that value to the user (perhaps using an ASK field) and the
user may type in a different value (say, "3")

What do you want to happen to that value "3"?

(And are we talking about a query that returns a single row, or what?)

Peter Jamieson

"NeedHelp" wrote in message
...
I have a Word document linked to an Access query. In the
query, it has a predefined numeric value that I would like
the user to be able to change from the Word document and
the have the query refresh using the new value.

Is this possible? I'm an Access programmer and have never
done any programming on Word.