Desperatly need help Report to Array, can anyone solve this?

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

Guest

Hello,

I hope somone can help me solve this problem! Noone seems to know

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
 
Hi,

Just a quick one, but you'll be best to use the source that the report is
based on - If you want it to run from within the report itself try using the
report's RecordSet property. Something along the lines of...

For i = 1 To Reports("rpt_Name").Recordset.Count
MyArray(i - 1) = Reports("rpt_Name").Recordset.Fields("fld_Name")
Next i

Remember to resize your array using Redim to make sure it's the correct size
(you'll need to get the number of records the recordset returns), and also
handle the fact that there may not be any records at all and you should be OK.

Cheers,

Stuart

p.s. Caveat - I haven't tested the above code snippet!
 
Unfortunently it dosn't work it says "Runtime-error '2593':

This feature is not available in an MDB

Dim parentarray()
ReDim Preserve parentarray(Report_UpdateReport.Count)

For i = 1 To Report_UpdateReport.Count
'parentarray(i - 1) =
Reports("UpdateReport").Recordset.Fields("parentid")
parentarray(i - 1) = Report_UpdateReport.Recordset.Field("parentid")
MsgBox parentarray(i)
Next i

The Report_UpdateReport.Count seems to work great but the
Reports("UpdateReport"). dosn't
 
Hi,

Sorry, it was just a basic example to give you an idea - and an example that
I hadn't tested!

So to make up for it...

Private Sub Report_Open(Cancel As Integer)
Dim rst As ADODB.Recordset
Dim i As Integer

Set rst = New ADODB.Recordset

With rst
.Open Me.RecordSource, CurrentProject.Connection, adOpenKeyset
If Not .EOF And Not .BOF Then
ReDim parentarray(.RecordCount)
For i = 1 To .RecordCount
parentarray(i - 1) = .Fields("parentid")
.MoveNext
Next i
End If

.Close
End With

Set rst = Nothing
End Sub

It works fine on my machine...

Cheers,


Stuart
 
Hey,

looks like we are on the right track but when i run it i get this message:

"The expression on Open you entered as the event property setting produced
the following error: procedure declartation does not match description of
event or procedure having the same name

* Th expression may not result in the same name of the macro, the anme of a
user-defined function, or [Event procedure].
*There may have been an error evaluating the function, event or macro.

andy idea?
 
Back
Top