Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Taking Data from Access to Word

Taking Data from Access to Word

Taking Data from Access to Word

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!

RE: Taking Data from Access to Word

What sort of fields are you trying to fill. If you give me an example I will try and help.

RE: Taking Data from Access to Word

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.

RE: Taking Data from Access to Word

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

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close