complex table manipulation via VBA (in ms access)

K

Keith G Hicks

I am trying to populate a table (word 2003) via automation in ms access.

My template word file is set up with a table as follows (sorry, I cannot get
all this to not wrap funny so my samples may not be as clean looking as I'd
like):
---------------------------------------------------------------------
| Customer / | Address | Values |
Phone/ |
| Cust # | |
| Fax |
---------------------------------------------------------------------
| FormField | | Bldg: FormField |
|
| | FormField | Autos: FormField |
FormField|
-------------| | Land: FormField |
FormField|
| FormField | | Mach.: FormField |
|
| | |
| |
---------------------------------------------------------------------

At the moment I have non bookmark bound form fields indicated above by
"FormField"

I need to end up with something similar to what's shown below. The number of
"rows" of course depends on how many customer records there are.

----------------------------------------------------------------------------
--------------
| Customer / | Address | Values
| Phone/ |
| Cust # | |
| Fax |
----------------------------------------------------------------------------
--------------
| George | | Building:
$500,000 | 213-6541 |
| | 123 Main | Autos: $
78,000 | |
----------------| Suite 1 | Land: $125,000
| 213-6544 |
| 12 | Elmville, MO 50121 | Machines: $750,000
| |
| | |
| |
----------------------------------------------------------------------------
--------------
| Harry | | Building:
$450,000 | 477-7500 |
| | 75 Elm | Autos:
$241,000 | |
----------------| Berkley, CA 91323 | Land: $ 90,000
| none |
| 15 | | Machines:
$621,000 | |
| | |
| |
----------------------------------------------------------------------------
--------------

So I not only need to get the correct data into each form field but I also
need to "append" a new properly laid out set of rows to the table for the
next record(s). I have no way of knowing in advance how many records there
will be and I cannot have blank rows.

Can anyone suggest a good way to handle this? In the past, I've done this
without tables and just set up tab positions. I'd place a single bookmark at
the start of the data and then tab to each column (but no table remember)
and then do a CR at the end of the line. This has always worked fine but my
client wants a fancier layout than that.

In addition, they want this to be a "form" (which is why I need the form
fields) so that end users can only edit the data in the form fields. I know
I need to programatically turn off protection when creating the doc in code
but then I turn it back on once the doc has been created.
Thanks in advance,

Keith
 
K

Keith G Hicks

I just realized this ought to be asked in the word.vba.general newsgroup so
I'm moving it there instead.

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