populate word template from a continuous form (1 Viewer)

AmyAimee

Registered User.
Local time
Today, 16:49
Joined
Oct 5, 2011
Messages
23
Is there anyway to populate a word template from a continuous form?

Currently, only one record from the continuous form appears in the word template, which is the the record that has the focus.

I'm using this code
Code:
        .ActiveDocument.Bookmarks("BookmarkOne").Select
        .Selection.Text = (CStr(Forms!FormName!FieldName))
 

JamesMcS

Keyboard-Chair Interface
Local time
Today, 14:49
Joined
Sep 7, 2009
Messages
1,819
Hmmm.... maybe you could use a recordset and some VBA automation to get what you want. Cycle through the records and send the data to word using automation, I mean.....
 

AmyAimee

Registered User.
Local time
Today, 16:49
Joined
Oct 5, 2011
Messages
23
Well actually, I'm having the same idea in mind but It's not about the idea, it's about the syntax.

How can I position the next record to be in a new line or a new row assuming that I'm populating a table in word.
 

JamesMcS

Keyboard-Chair Interface
Local time
Today, 14:49
Joined
Sep 7, 2009
Messages
1,819
That's the automation part. I'm not 100% sure on the syntax to be honest, but I'm thinking something along the lines of the following in VBA:

Create a table
Populate each cell with the data from the recordset
Insert a page break
Move to next record

Repeat the above until EOF.

There'll be a load of stuff on the web about VBA automation for Word.

Incidentally, does it have to be a word doc? Could you just create a report and use that?
 

AmyAimee

Registered User.
Local time
Today, 16:49
Joined
Oct 5, 2011
Messages
23
Unfortunately yes, it has to be a word doc. Currently the code I wrote in post #1 works fine for fields from single form, but when it comes to fields from continuous form, I only can get the first record. Probably I should learn some Word VBA!
 

JamesMcS

Keyboard-Chair Interface
Local time
Today, 14:49
Joined
Sep 7, 2009
Messages
1,819
A macro might do the trick. Or you could use that code in combination with a recordset and see if that works?
 

vbaInet

AWF VIP
Local time
Today, 14:49
Joined
Jan 22, 2010
Messages
26,374
Populate it from the recordset and loop through OR get a clone of the form's recordset and loop through it.
 

Users who are viewing this thread

Top Bottom