Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access from Word (Access 2000/Word 2000)

    Can I write Word VBA code to add records to an Access database? If so, what approach do I need to take to access the database?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access from Word (Access 2000/Word 2000)

    Yes, you can write code to do what you want. Take the ADO approach. It's easy and powerful.

    Abundant ADO training resources exist all over the net, but <A target="_blank" HREF=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmscadocodeexamples.asp>this link</A> should get you started.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access from Word (Access 2000/Word 2000)

    Thanks! That confirms my hopes and suspicions, since I've done ADO in other contexts before, like accessing Oracle or SQL Server. My question now is, what is the correct connection string for an Access database? Assume no password protection. The examples I see online do not quite get me there.

    Regards,
    Dale

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access from Word (Access 2000/Word 2000)

    It depends on whether you have created an ODBC system or user DSN or not. I go for the DSN-less approach.

    Something like this should work:

    Set cn = New ADODB.Connection
    cn.ConnectionString = _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:datafilesmydata.mdb"
    cn.Open
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access from Word (Access 2000/Word 2000)

    Cool! Yes, ODBC can be a pain, especially if distribution is an issue. How can I be use which version of OLEDB to specify?

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access from Word

    If 4.0 does not work on your system, drop to 3.5. A visit to the Access forum will get you a better understanding of the issues.

    If you are exploring ADO and Access in depth, be sure to post over there.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Access from Word (Access 2000/Word 2000)

    If you're using Access 2000 as stated, then you should be using 4.0. Which SR of Office are you running?
    Charlotte

Posting Permissions

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