Revision: 45148
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 26, 2011 06:23 by CaptainProton
Initial Code
Sub RunAccessQuery() Dim MyDatabase As DAO.database Dim MyQueryDef As DAO.QueryDef Dim MyRecordset As DAO.Recordset Dim i As Integer Set MyDatabase = DBEngine.OpenDatabase _ ("D:\my Documents\Database2.accdb") Set MyQueryDef = MyDatabase.QueryDefs("Query3") With MyQueryDef .Parameters("[jahrpar]") = Range("A1").Value End With Set MyRecordset = MyQueryDef.OpenRecordset Sheets("Main").Select ActiveSheet.Range("A6:K10000").ClearContents ActiveSheet.Range("A7").CopyFromRecordset MyRecordset For i = 1 To MyRecordset.Fields.Count ActiveSheet.Cells(6, i).Value = MyRecordset.Fields(i - 1).Name Next i End Sub
Initial URL
Initial Description
Initial Title
Running Access Parameter Queries from Excel
Initial Tags
query, excel
Initial Language
Visual Basic