Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Word form fields 1

Status
Not open for further replies.

MikePalm

Programmer
Feb 6, 2002
34
0
0
US
I have several word documents that have a number of form fields on them. I want to be able to open the document and pass it data for the fields and have the data displayed in the fields. Is there a way to do this? I have not found any documentation on this subject.

Is there a good place to go to get documentation on using Word Documents with form fields. The online help for word is not very detailed.

I am using Microsoft word 2000 and Word XP.

Mike
 
Dreamboat,

What I mean by "pass it data" is that I want the document to display for the user with data from a database (SQL Server) filled in on the form. The forms are contract forms. The user fills in the information in our application, and then chooses to view the form. I want the form to be displayed with the data the user entered in our database. We have several forms with the same repeated information, like name and address. This approach will allow the user to enter the data once and view it on multiple forms. They can also view and print the form multiple times without having to re-enter the information. We are also able to use the data from the forms for reporting.

Mike
 
Hi
If these forms are user forms and can be edited then you need an on form open sub
with the lines
fielddata = userformname.textbox1(name of textbox).value
for each entry you want to see
 
Thanks Ninash,

can the data be read from a file, or retrieved from a SQL Server database?

Mike
 
You can make the document a Mail Merge document linked to data in an access database.
Access can then get data from the SQL server and maybe you can go directly.

I don't have any experience with SQL server.
 
Hello,

first you should decide, if 1) you want to pass the data from your application to word (then your application can control word) or if 2) you want word to get the data from the database, where your application stored the data.

1) You could use Microsoft ActiveX to open, print and close documents and insert data at a bookmark or into a form field. Generally you can do everything that is available in Visual Basic for Word.

2) You can write Visual Basic macros (Word VBA). Open the visual basic editor from the extra/macro menue and look at the online help there. In the online help i found that you can use DAO (data access object) to select data from a database:

Set Db = OpenDatabase _
(Name:="C:\Microsoft Office\Office\" _
& "Samples\fpnwind.mdb")
Set Rs = Db.OpenRecordset(Name:="Shippers")
For I = 0 To Rs.RecordCount - 1
Selection.InsertAfter Text:=Rs.Fields(1).Value
Rs.MoveNext
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertParagraphAfter
Next I
Rs.Close
Db.Close

Thomas

 
You have to write an SQL query to output the data to access
However my knowledge of sql is very limited
 
I am not sure but you might be able to set up a link to the query in SQL via the odbc method in access
I hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top