how to connect Microsoft access to Excel or retrieve data from access to excel using vba
1. Add reference to ADO Lib in Excel
2.Create a Active X button and Add the following code
StrSql = "Select * from YourTable"
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0.;Data Source=C:\Users\your db location \db.accdb"
rst.Open StrSql, Cn
Sheet1.Cells(10, 1).CopyFromRecordset rst
rst.Close
Cn.Close
PS - replace YourTable with ur table name , and enter data source of the accdb location.
1. Add reference to ADO Lib in Excel
2.Create a Active X button and Add the following code
StrSql = "Select * from YourTable"
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0.;Data Source=C:\Users\your db location \db.accdb"
rst.Open StrSql, Cn
Sheet1.Cells(10, 1).CopyFromRecordset rst
rst.Close
Cn.Close
PS - replace YourTable with ur table name , and enter data source of the accdb location.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.