Printing a variable length array

  • Thread starter Thread starter Stuart
  • Start date Start date
S

Stuart

I would like to print a 1 dimensional array, which
contains simple text. The size of the array is
potentially very large, so putting it all into a single
label will not work. Any suggestions?
 
You can use code in the report like
For i = 1 to UBound(arYourArray)
Me.CurrentX = 500
Me.CurrentY = i * 400
Me.Print arYourArray(i)
Next
 
Thanks very much, it works! I appreciate the
suggestions, as there is no help topic in Access2002 VBA
for the print method.

Stuart
 
I should say it sort of works. Two problems have come up.
1. I get an overflow after about 80 lines.
2. I don't know how to advance the page. Everything
prints on page 1....

Thanks, Stuart
 
You may need to bind your report to some table with multiple records. It is
hard to answer unless the number of pages or some number of records can be
determined. The easiest method would be to place the array into a table and
then binding the report to the table.
 
OK, I thought that might be the case. MS Access is
rather data oriented. This sort of thing would have been
very simple in COBOL or C, but c'est la vie.

Thanks for your help, Stuart
 
Stuart said:
I would like to print a 1 dimensional array, which
contains simple text. The size of the array is
potentially very large, so putting it all into a single
label will not work. Any suggestions?

As long as you're not trying to use sorting and grouping,
let's try an unbound report for this. Add a textbox to the
detail section and make the section only as tall as the text
box.

The logic to control this kind of report is to initialize
the array (or a recordset) in the report's Open event using
module level declarations.


Dim thearray(xx) As whatever
Dim lngLoopCounter As Long

Sub Report_Open(
' initialize the array values and sort them if needed
. . .
lngLoopCounter = 0
End Sub

Sub Detail_Format(
Me.textbox = thearray(lngLoopCounter)
lngLoopCounter = lngLoopCounter + 1
If lngLoopCounter <= UBound(thearray)
Me.NextRecord = False
End If
End Sub

If there's any cleanup to do, do it in the report's Close
event.
 
Hey, it works!!!
Much thanks.

One small modification, it needed to be in the OnPrint,
not the OnFormat section.

And one small shortcoming, pages thinks there is one
page, so page counter says "page 1 of 1, page 2 of 1,
etc."

Thanks again, Stuart
 
Stuart said:
Hey, it works!!!
Much thanks.

One small modification, it needed to be in the OnPrint,
not the OnFormat section.

And one small shortcoming, pages thinks there is one
page, so page counter says "page 1 of 1, page 2 of 1,
etc."

That's weird! I went and tried it and everything worked
fine using the Format event, until I added a text box with
=Pages. I must not have ever done that before!?

I guess using Pages in an unbound report just doesn't work
particularly well ;-(
 
Back
Top