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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Taking Data from Access to Word 1

Status
Not open for further replies.

InsaneProgrammer

Programmer
Jan 17, 2001
44
US
I have a word template and I want to fill some of the fields with data in an access db. I've tried writing some code using DAO but I'm not having much luck. Does anyone have any sugestions? THANKS!
 
What sort of fields are you trying to fill. If you give me an example I will try and help.
 
My database tracks the status of projects through our office. Who it is assigned to, when it was assigned, client info, and varies steps in the process. When a project is completed there is a form that is filled out by hand and signed. I created a template based on the form and would like to extract some information from access to speed up the process of filling out the form. Unfortunately, I can't just create a report in access because there is a whole bunch of other info that is also needed. Currently, when the completion data is entered on a project the word template automatically opens for the user to complete. It would really be useful if the name of the person working on the project, project cost, and various info could be taken directly from the database at this point.
 
This is a simple bit of code that obtains the phone numbers from a database and places them in a combo box. With your example it sounds like you would just use some labels and fill the caption with the records you require.

Dim VodaDB As Database
Dim VodaRS As DAO.Recordset

Private Sub GetPhoneNumbers()

Dim PhoneNumbers() As String
Dim PhoneNumbersEN As Integer
Dim FoundRecords As Boolean

PhoneNumbersEN = 0
FoundRecords = False

Set VodaDB = DBEngine(0).OpenDatabase("c:\voda\d2210f0t.mdb")

Set VodaRS = VodaDB.OpenRecordset("SELECT CTN FROM CTN")

Do While Not VodaRS.EOF
ReDim Preserve PhoneNumbers(PhoneNumbersEN)
PhoneNumbers(PhoneNumbersEN) = VodaRS!CTN
PhoneNumbersEN = PhoneNumbersEN + 1
FoundRecords = True
VodaRS.MoveNext
Loop

ComboBox1.List = PhoneNumbers()
End Sub


You have to make sure the DAO object library is loaded in word to make this work. It is under Tools-References in VB Editor.

If you require anymore assistance I would be happy to help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top