PDA

View Full Version : vba used to retrieve data from sql server into access



wedd
11-17-2010, 11:38 AM
Hi, all! Just wondering how to use vba code to retrieve data from a sql server 2005 server into access 2007 using vba? I will appreciate it if you have sample code.


Thanks for your solutions:clap:

CreganTur
11-18-2010, 11:03 AM
There are a few different ways. If you have rights on the server then you can just create a linked table to the server. If that's not an option, then you can use ADO to connect to the database and run a query to pull it down.

ADO is a very large topic so it's best to google it and start learning- the best book I can reccomend is Access 2007: programming by example with VBA, XML, and ASP. It will cover ADO in great detail and get you on your way. Also, connectionstrings.com is your best source on the format of connection strings for ADO.