Importing access data to form

W

writetodaveo

Hi there,

I have an access query that returns a lost of names given certain
criteria. The list of names changes as the criteria is changed. I would
like to export this list to a Word form table, with a checkbox next to
each name entry. The problem I think I will have is that the length of
the list of names will change each time, and I would need the word
document to add/remove rows and checkboxes in the table, depending on
the list length.

The idea is, this word form can be emailed to someone to complete and
then sent back to me.

Is this possible?

Thanks - David
 
C

Cindy M -WordMVP-

I have an access query that returns a lost of names given certain
criteria. The list of names changes as the criteria is changed. I would
like to export this list to a Word form table, with a checkbox next to
each name entry. The problem I think I will have is that the length of
the list of names will change each time, and I would need the word
document to add/remove rows and checkboxes in the table, depending on
the list length.

The idea is, this word form can be emailed to someone to complete and
then sent back to me.

Is this possible?
Yes, it should be possible. The most efficient way to create a Word table
is to concatenate the information into a delimited string (tab-delimited,
for example). Dump this into a Word range, then use the ConvertToTable
method. This is all explained in the following article

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_wd20
03_ta/html/OfficeWordAutomatingTablesData.asp

In this case, you should place an "empty" tab at the beginning of each
"row", so that an empty column is generated. You can then loop through
the cells in this first column and insert a checkbox. I recommend you use
a checkbox from the FORMS toolbar, as this won't activate macro security
on the recipient's machine. After you've completed the document, you
should protect it as a form so that the checkboxes work.

Record inserting a checkbox form field and protecting the document to get
the basic syntax. Here's a sample to get you going:
Dim rw as Word.Row
Dim rng as Word.Range

For each rw in oTbl.Rows
Set rng = rw.Cell(1).Range
rng.Collapse
ActiveDocument.FormFields.Add( _
rng, wdFieldFormCheckBox)
Next

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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