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

Need to get a record from MS Access using Word VBA

Status
Not open for further replies.

Dwight3238

Technical User
Aug 19, 2003
11
US
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.

Can someone help.

 
Just an added note;
I need the record information to be stored in a varible

Thanks
 
Hi,

Create a subReport base on a query, that do the total without grouping, and add it at the end of your report.

jp@solutionsvba.com


Jean-Paul
Montreal
mtljp2@sympatico.ca
 
Hi,

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.

That's it in a thumbnail. :)

Skip,
Skip@TheOfficeExperts.com
 
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.

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top