Refresh an Access Query using VBA code in Excel
Set the reference to the Microsoft ActiveX data as you suggested, entered
the path and name of my mdb-file and also the name of the query. Ran the code
but no readcion in my Access database.
-Does the code you have suggested run the query in the backgound?
-The Access make table query requires some interaction confirming that data
is to be overwritten, a new fil will be created etc, does your code
automatically conform all the questions?
Is it necessary to "close down" Access after runnuing the query?
/PG
"Patrick Molloy" wrote:
set a reference to the Microsoft Active data Obkject 2.6 Library
(Tools/references)
Dim con As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim SQL As String
MyFile = "Risk.mdb"
SQL = "qsecurities" ' this is th ename of the query
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MyFile
rst.Open SQL, con, adOpenStatic
"Peter G" wrote:
I have linked data in an excel workbook from a tabel in an Access database
The table has been created from a Make tabel query in the same database. For
the data in the Access table to be up to date I need to run the Access query.
Can somone suggest a suitable VBA code for me to run in Excel that will
connect to the Access database and run (refresh) the query.
|