Results 1 to 13 of 13
  1. #1
    Star Lounger
    Join Date
    May 2002
    Location
    Hawaii
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access & Word (2000/SP-3)

    I have a database. I have a Word template. And I have a need to take data from the database and place it in the template (document from the template really).

    My question is how do I approach getting data into the Word document? Do I use Word's Database field or do I use Access to send data to Word?

    If I use Word, then I need some way to be able to specify a specific value that denotes the specific record I want to retrieve. Once the record is found, various fields are used from that record to fill in the blanks in the template. How do I retrieve the value then query the database for the correct record?

    If I use Access, how do I link the proper fields to the correct blanks in the Word document?

    Seems to me a this should be simple but I just don't see it.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access & Word (2000/SP-3)

    One way is to create a query in the Access database that retrieves only the specific record from the table, and use this query as data source for a mail merge in Word. You can then use merge fields to put the value of fields from the record into the Word document.

    Is this enough information to get you started, or do you need more detailed instructions?

  3. #3
    Star Lounger
    Join Date
    May 2002
    Location
    Hawaii
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access & Word (2000/SP-3)

    I don't want to waste your time going into too much detail. Is there a site out there someplace that explains how to do something like this? Or an old message thread? If not, then a little more detail would be helpful. Thanks.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access & Word (2000/SP-3)

    How are you going to specify the record you want to get into Word? It is selected on a form, or ...?

  5. #5
    Star Lounger
    Join Date
    May 2002
    Location
    Hawaii
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access & Word (2000/SP-3)

    That's one of my questions. If I'm using Access to fill in the document, I'll just press a button on the form of the current record. All I'll need to know is how to get the data to the document.

    Now, if I am using Word to get the data, then I'm unsure how to do that. I would expect to run a macro from an event (say, the LostFocus() event) but don't know where to go from there (if this is the best way).

    I hope this is clear.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access & Word (2000/SP-3)

    OK, if you want to send the current record on a form to Word, a slightly different solution may be in order. See ACC2000: Sending the Current Record to Word 2000 with Automation for a description.

  7. #7
    Star Lounger
    Join Date
    May 2002
    Location
    Hawaii
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access & Word (2000/SP-3)

    Thanks. This should do it. I just wish I had access to all the automation reference material. It makes it tough programming this stuff using the VB for Applications help files, code builder, object library and references.

    Have you seen any examples of going about thias the other way -- from Word to Access instead of Access to Word? I'm just curious as how much more work it would be. I guess you can never learn too much :-).

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access & Word (2000/SP-3)

    Helen Feddema has examples of Automation on her website; if you click Code Samples and scroll to the end, you'll find an example of going from Word to Access.

    Also see OFF2000: Microsoft Office 2000 Automation Help File Available and FILE: OFFAUTMN.EXE Discusses Office 97 and 2000 Automation and Provides Sample Code.

  9. #9
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Access & Word (2000/SP-3)

    I think Bryan Carbonnell (http://www3.sympatico.ca/carbonnb/bryan/index.html) has something like that as an example on his web site. You might also find our Automation tutorial of interest - it has a number of links to detailed information about the subject.
    Wendell

  10. #10
    Star Lounger
    Join Date
    May 2002
    Location
    Hawaii
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access & Word (2000/SP-3)

    Wow, thanks for all the info. I'm sure to be kept reading for awhile.

    Also, I found a different way that works better for me. Because I am using form templates, the bookmark method didn't work unless I unlocked the form. I needed a way to do the same thing but without unlocking the document (many of the documents I use were created by external resources and have them protected to make them unchangeable.)

    So, instead of something like (this example is from the MS code you linked me to):

    .ActiveDocument.Bookmarks("City").Select
    .Selection.Text = (CStr(Forms!Employees!City))
    .ActiveDocument.Bookmarks("Region").Select
    .Selection.Text = (CStr(Forms!Employees!Region))

    I use:

    .ActiveDocument.FormFields("City").Result = Forms!Employees!City
    .ActiveDocument.FormFields("Region").Result = Forms!Employees!Region

    Now I am able to send the data to a locked form. Also, the code seems a little cleaner.

    Do you know of any downsides to the method I use here? It seems to work but until I build and distribute a complete application, I won't know of the pitfalls.

    Again, thanks for your help.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access & Word (2000/SP-3)

    It should work, but where I work, users hate documents protected for forms, because so many options are disabled in unprotected sections. It makes many documents unusable.

  12. #12
    Star Lounger
    Join Date
    May 2002
    Location
    Hawaii
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access & Word (2000/SP-3)

    I'm a REALTOR by trade and the documents we use are contracts that were designed in Word. If you've worked with REALTORs, you know you don't want them to mess with the wording of a contract :-).

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access & Word (2000/SP-3)

    OK, point taken <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •