Loading an array from a table

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?
 
J

John Nurick

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.
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top