Need to edge out the competition for your dream job? Train for certifications today.
Dim acc As Object
Dim db As Object
Dim qd As Object
Dim r As Long
Dim arr() As Variant
Const db_path As String = "C:\folder\subfolder\database.mdb"
Set acc = CreateObject("Access.Application")
Set db = acc.CurrentDb
ReDim arr(1 To db.QueryDefs.Count, 1 To 2) As Variant
For r = 1 To UBound(arr, 1)
' QueryDefs is a zero-based collection
Set qd = db.QueryDefs(r - 1)
arr(r, 1) = qd.Name
arr(r, 2) = qd.Sql
Set qd = Nothing
Set db = Nothing
Set acc = Nothing
[a1] = "Query Name"
[b1] = "SQL Statement"
Range(Cells(2, 1), Cells(1 + r, 2)).Value = arr
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
This course teaches how to install and configure Windows Server 2012 R2. It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).