Mail merge: Word/Access ok but Access/Word is problem

G

Guest

Strange situation happening.

I'm running Access 2000 and Word 2000. Have modified previously clumsy
mail-merge system in customer database to operate more tidily from a menu
form within Access. It worked before - from a menu form - but I have extended
the Access Query that the Word document is based on to include user input
parameters for year and "prior to" date. Here's the problem:

Mail-merge document works fine and is linked to data-source ok if I call it
up in Word. But calling from within Access (dynamic link within a command
button on menu form) the document opens but all merge buttons in Word are
greyed out and the document has not found the data-source.

Directory structure: the document is one directory down from the database in
the same tree.

Anyone any clues as to why this is happening?

Regards, Keith
 
G

Guest

Thanks Albert. The merge single record could be useful in future, but I don't
see how I can do anything with your demo file for my current situation, and
I'm about as green as grass when it comes to using VB.
Keith
 
A

Albert D.Kallal

Hum, what I would do is remove the paramters from the query (did that ever
work anyway?)

Then, simply build a form that is UN-BOUND with two text boxes

one text box is for year (call it txtYear)

one text box is for "before date" (call it txtBeforeDate)

The code to use my merge system would thus be:

dim strWhere as string
dim strSql as string

strWhere = "(Year([InvoiceDate]) = " & me!txtYear & ")" & _
" and (InvoiceDate <= #" &
format(me!txtBeforeDate,"mm/dd/yyyy") & "# )"

strSql = "select * from myTable where " & strWhere

MergeAllWord strSql

The above would do what you want. As for why you existing setup don't work,
it not clear what code, or how you are launching word, nor is it clear how
you are having word establishing a connection to the access data.

The above is only 5 lines of code.....
 
G

Guest

Thank you Albert, very much. I expect thats the way I'll go, but right now
I've run into a time problem and will have to defer a little.

To answer your questions, I accessed the Word merge document from a command
button on a menu form (not the "switchboard" but a form created to do what a
"switchboard" does). The command button was installed from the toolbox with
Wizard help, and I used "browse" within that wizard to select the merge file
and set as a hyperlink.

As to the other way around - accessing the database from the open Word
document, that works fine. It was set up through the mail-merge wizard, first
the databse being selected and when the dialogue box opened for the object to
be selected, the parameter quesry was selected from the list provided within
that dialogue box.

Oh, and yes, if I remove the parameters from the query it works fine both
ways. The first parameter was [Please enter year: (yyyy)] and the second was
<[For dates prior to: (dd/mm/yyyy)]. These reference two different underlying
fields representing the year of the program and the actual date of customer
application, and function exactly as designed to when the document is called
up in Word and Word does the data accessing. I'd really like to understand
why what seems to be a standard enough process within Access's built in
functions, uncomplicated by user-written code doesn't seem to work as it
should. :-(

Thanks for your help. Keith :)
 

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