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


/ Published in: Visual Basic
Save to your folder(s)

How to populate an array with recordset data


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.