title: Convert recordset to array
body: <p>I am  quite new to access and sql. Trying to convert the data in my recordset into an array (Excel VBA) so that I could work with the data without pasting the data on a spreadsheet. </p>
  
  <p>Did some research and most sites mentioned that GetRows function would work but I got an run-time error '3021'. Any advice on how to fix this, please? Thanks!</p>
  
  <pre><code>Dim conConnect As Object
  Dim cmdCommand As Object
  Dim rstRecordSet As Object
  Dim DBPath, StrCon As String
  Dim tblarray As Variant
  
  Set conConnect = CreateObject("ADODB.Connection")
  Set cmdCommand = CreateObject("ADODB.Command")
  Set rstRecordSet = CreateObject("ADODB.Recordset")
  DBPath = "C:\Users\Documents\DbMhours.accdb"
  
      conConnect.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &amp; DBPath &amp; _
      ";Mode=Read|Write"
  
      conConnect.CursorLocation = adUseClient
      conConnect.Open
  
      With cmdCommand
          .ActiveConnection = conConnect
          .CommandText = "SELECT * FROM tblOverallStats;"
          .CommandType = adCmdText
      End With
  
      With rstRecordSet
          .CursorType = adOpenStatic
          .CursorLocation = adUseClient
          .LockType = adLockOptimistic
          .Open cmdCommand
      End With
  
      'Call StatsSum function in module
      tblarray = StatsSum (rstRecordSet)
  
      rstRecordSet.Close
  
      conConnect.Close
  
  
  Function StatsSum(Summary As Object) As Variant 'Input to be recordset from workbook
  
      tblarray = Summary.GetRows
  
  End Function
  </code></pre>