Posted By

martinbrait on 07/29/19


Tagged

array dao recordset


Versions (?)

[vba-access] Peupler un tableau avec le retour d'un recordset


 / Published in: Visual Basic
 

How to populate an array with recordset data

  1. 'nécessite l'activation de la référence DAO
  2.  
  3. Public Sub Foo()
  4. Dim aFoo As Variant
  5. Dim db As DAO.Database
  6. Dim rst As DAO.Recordset
  7.  
  8. Set db = DBEngine(0)(0)
  9. Set rst = db.OpenRecordset("tblFoo")
  10.  
  11. With rst
  12. .MoveLast
  13. .MoveFirst
  14. aFoo = .GetRows(.RecordCount)
  15. End With
  16.  
  17. rst.Close
  18. db.Close
  19.  
  20. End Sub

Report this snippet  

You need to login to post a comment.