[AccessD] Dynamic number of rows on a report

Stuart McLachlan stuart at lexacorp.com.pg
Wed Mar 30 11:06:54 CST 2005


On 30 Mar 2005 at 11:08, Joe Rojas wrote:

> I was trying to think of a way that would allow the number of "lines" that
> are printed on the report to be dynamic and dependent on the order quantity
> that is entered prior to printing the report.
> 

You can do exactly that in the Format event Here's an example.   Following 
is written on the fly and may need a bit of debugging:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim loopcount As Long

'Following parameters are in twips (1/1440 inches)
Dim lngLineEnd as Long 'Twips to end of line
Dim lngMargin as Long  'Left margin of lines
Dim lngStartY as Long ' height of Detail section before first line
Dim lngSpacing as Long ' space between lines

lngStartY = 1440       ' 1 inch
lngLineEnd  = 8640      ' 6 inch
lngMargin = 1440      ' 1 inch
lngSpacing = 360     ' 1/4 inch 

'reset the length of the detail section
Detail.Height = lngStartY + lngSpacing * OrderQty

'Draw the lines
lngYCoord = lngStartY 
For loopcount = 1 To OrderQty
   lngYCoord = lngYCoord +  lngSpacing
   Line (lngMargin, lngYCoord )-(lngLineEnd, lngYCoord )
Next

End Sub
-- 
Stuart





More information about the AccessD mailing list