User Parameter Query (Acess 2003) to Word Template

mick5003

New Member
Joined
Sep 8, 2010
Messages
8
Hi,

i am struggling with how to effectively 'export' the results of a query into a word template, where the query prompts the user for a query parameter.

I have set up the word template (.doc) and added in bookmarks to send the query data too but I cannot seem to get my head round how to send the data.

I apologise for the vagueness of this request but I am very new to Access (2003) and all my knowledge is from the 'for dummies' collection of books.

I just want to be able to press a button from my 'switchboard' which runs the query, opens the word document and then sends the data to the specified fields.

Can anyone help me please?
 

Some videos you may like

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,483
Wouldn't this be easier to do in Access as a Report. If you have more than 1 single record going into your word document you would get issues because of the amount of times it would need to run?

Code to open word could be:

You would need to reference the query

Function SendWord()
Dim wrd As Word.Application
With wrd
.Documents.Open "Enter the Path.doc"
.Selection.GoTo What:=wdGoToBookmark, Name:="gooday"
.Selection.TypeText Text:="Enter Text"
.Visible = True

End With

End Function
Also look at the following as a suggestion http://www.datapigtechnologies.com/AccessMain.htm

And look at
Create Form Letters Without Mail Merge
 

mick5003

New Member
Joined
Sep 8, 2010
Messages
8
Thanks Trevor, I will try this out.

I have ruled out using Access Reports as I need to add more information to the document once it has been created.

Also, in every instance, the query I am using will only ever return one record.

If you have any other thoughts please let me know.

Thanks again,

Mick
 

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,483
Then pass the query results into a form and you can use the form object to pair up with the Bookmarks

So from the code I added you would amend that to the form control name that will give you the result you need.

Selection.GoTo What:=wdGoToBookmark, Name:="gooday"
.Selection.TypeText Text:=me.txtName.value
So from this example you would copy the selection.goto etc and change the bookmark name to the ones you are using and then the me.txtname.value to the controls on the form.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,330
Messages
5,467,977
Members
406,562
Latest member
tobruk

This Week's Hot Topics

Top