I'm creating a Word XP template using VBA and I needs to get a record from a MS Access database table. I have tried every example that I can find but none seem to work.
You'll need to set a VB reference to an ADO or DAO database/recordset objects library.
You'll need to set a connection object and a recordset object.
Your recordset object will have your SQL as an argument and, if sucessful, will return a recordset of at least one row. You can then manipulate the recordset object to extract discrete values.
Thanks guys for the input it really helped and I have it working.
Just one more question concerning this issue.
I added the Active X reference to my project. Does that follow the template if I distribute it to other users? Also, I used Access as my datasource, do my users have to have MS Access for Word to read these files?
You users will have to set a reference to the ADO library that you are using. Here's a link to a MS Knowledge Base artlcle on creating a reference in code...
XL2000: How to Programmatically Create a Reference
However, they will not need to have MS Access. They will not be able to open the MS Access database, but your program in MS Word will do all the heavy lifting anyhow.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.