Loading an array from a table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I create an array and load it with data from a table? Do I need to
create a user defined data type?
 
Hi Joe,

IME it's very seldom necessary to do this, because most of the things
one might want an array for can be done better either with a SQL
statement or by working with a recordset - which you have to do anyway
in order to get the data into an array.

That said, the general idea is:

Dim arRecords As Variant
Dim rsR As DAO.Recordset

Set rsR = CurrentDB.OpenRecordset("MyTable", dbOpenSnapshot)
arRecords = rsR.GetRows(99999)
rsR.Close

See Help on GetRows for more.
 
JoeA2006 said:
How can I create an array and load it with data from a table? Do I need to
create a user defined data type?


Open a recordset with the data, then use the GetRows method.
Check Recordset in VBA Help for details.
 
Back
Top