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?
 

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,362
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,362
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.
 

Forum statistics

Threads
1,082,139
Messages
5,363,363
Members
400,731
Latest member
Jackserver

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top