Need help deperatly, fill array

T

TheGerman

Hello,

I hope somone can help me solve this problem!

I need to fill an array with Data from a Report!


For i = 1 To Report_UpdateReport.Count

myarray(i) = ?

Next i

How do i fill the array with the information? People suggest me to use the
..EOF command but access dosn't seem to find that command.
I would highly appriciate it if you could help me fill this array. The
field in my report i want is called "parentid" and the reports anme is
UpdateReport

Thank you very much!

~Daniel
 
J

John Nurick

Hi Daniel,

You probably need to work with the query or table that is the report's
data source, not with the report itself. Then one way to proceed is with
something like this air code:

Dim rstR As DAO.Recordset
Dim arRows As Variant

'Open Recordset
Set rstR = CurrentDb.OpenRecordset _
("SELECT ParentID FROM MyQueryOrTable;")

rstR.MoveLast 'do this to ensure correct RecordCount
rstR.MoveFirst
arRows = rstR.GetRows(rstR.RecordCount)

GetRows() provides a two-dimensional array, with the first index
representing fields and the second records. Hence to access the first
(and in this example only) field in the third record you would use

arRows(0, 2)

If you must have a one-dimensional array you will need to iterate
through the recordset using MoveNext, and assigning the field value to
the appropriate array element.
 

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