Creating a table at the end of a document and populating with data

S

SJ

Hello everyone,

Could some kind soul please offer me some starting code for the above?

I'd be in Access.
I'd be using a document variable such as WordDoc

I do a mail merge then have a document sitting there and now they want a
Schedule in table form at the end.

So what i'm looking to do is to add a table with probably a set number of
columns, say 4 or 5, and then start to fill out the table with data from
the database.

So i'd need to see how to create the table at the end of the document and
then how to access the fields so that I could insert the appropriate data.

oh yes, would only know the number of rows required after running query.

Thank you for reading...
 
J

Jezebel

Something along these lines --

Dim pTable as Word.Table
Dim pIndex as long

With WordDoc
pIndex = .Range.end - 1
set pTable = .Tables.Add Range:=.Range(pIndex ,pIndex ), NumRows :=
RS.RecordCount, NumColumns:=4
End With

for pIndex = 1 to RS.RecordCount
pTable.Cells(pIndex,1) = pRS(1)
pTable.Cells(pIndex,2) = pRS(2)
:
Next
 
P

Peter Jamieson

You can always consider doing it using a DATABASE field in the document.
However, you have little control over the layout and Word is also capable of
getting rather confused between the DATABSE's data source and the mail
merge's data source.

Peter Jamieson
 

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