Using the Line Method to Draw Horizontal Lines

V

Velcerick

Sorry if this ends up as a double post... it didn't show up on the boards
more than an hour after I thought I posted it...

I need to print horizontal lines across the detail section of a report, with
more lines depending upon the height of the section. I believe that the
problem with the below code lies in my ability to obtain the current height
of the detail section when set to "CanGrow". Any suggestions or corrections
would be greatly appreciated.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim inHeight As Double
Dim lineSpace As Double
Dim inStep As Integer

inHeight = Detail.height
inStep = 1
lineSpace = 1440 * 0.1875

Do While inHeight > lineSpace
Me.Line (0, inStep)-(7.5 * 1440, inStep)
inStep = inStep + 1
lineSpace = inStep * 1440 * 0.1875
Loop

End Sub
 
V

Velcerick

Velcerick said:
Sorry if this ends up as a double post... it didn't show up on the boards
more than an hour after I thought I posted it...

I need to print horizontal lines across the detail section of a report, with
more lines depending upon the height of the section. I believe that the
problem with the below code lies in my ability to obtain the current height
of the detail section when set to "CanGrow". Any suggestions or corrections
would be greatly appreciated.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim inHeight As Double
Dim lineSpace As Double
Dim inStep As Integer

inHeight = Detail.height
inStep = 1
lineSpace = 1440 * 0.1875

Do While inHeight > lineSpace
Me.Line (0, inStep)-(7.5 * 1440, inStep)
inStep = inStep + 1
lineSpace = inStep * 1440 * 0.1875
Loop

End Sub

Note: The line that says Me.Line (0,inStep)-(7.5*1440, inStep) should be
Me.Line (0,lineSpace)-(7.5*1440, lineSpace)

When I run this code I only get one line.
 
M

Marshall Barton

Velcerick said:
When I run this code I only get one line.


The CanGrow height of a section is not available until the
Print event. Use that instead of the Format event.
 
V

Velcerick

Many thanks to the posters on this board. Makes me I wish I could contribute
more. Anyway, a combination of the OnPrint advice of Marshall Barton and
some other info by S Lebans gleaned through searching that said to use
Me.Height instead of SecDetail.Height I was able to get it to work. Now to
tweak it so the height of the lines jives precisely with the spacing in my
textbox.

Thanks Again
 
M

Marshall Barton

I missed a subtle bug in your code.

The line:
lineSpace = inStep * 1440 * 0.1875
should be:
lineSpace = inStep + 1440 * 0.1875

I may have missed something else too, so check your code
carefully and try using Debug.Print or the Watch Window to
help track down simple logic and/or calculation errors.
 
M

Marshall Barton

Marshall said:
I missed a subtle bug in your code.

The line:
lineSpace = inStep * 1440 * 0.1875
should be:
lineSpace = inStep + 1440 * 0.1875

I may have missed something else too, so check your code
carefully and try using Debug.Print or the Watch Window to
help track down simple logic and/or calculation errors.

Scratch this. I was wrong when I thought I made a mistake.

As you've already figured out, the other issue really was
the Section().Height instead of Me.Height, sorry for all the
confusion.
 

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