Hi,
Basically I have an Excel 2007 file that is linked to an Access 2007 database to get the data. Deleting/Writing to the database is no problem.
However, when I refresh my queries (as per the code below) on a worksheet the Access database stays open (the Access .laccdb file is shown). How can I close the connection? Here is the refresh code that leaves the database open:
The code I am using to write SQL to the database is as follows:
and I end it with:
Thank you for any help!
Basically I have an Excel 2007 file that is linked to an Access 2007 database to get the data. Deleting/Writing to the database is no problem.
However, when I refresh my queries (as per the code below) on a worksheet the Access database stays open (the Access .laccdb file is shown). How can I close the connection? Here is the refresh code that leaves the database open:
Code:
Sheets("Actuals").Select
Range("A1").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
The code I am using to write SQL to the database is as follows:
Code:
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & "Data Source=" & Sheets("Import").Range("H1").Value
and I end it with:
Code:
cn.Close
Set cn = Nothing
Thank you for any help!