Multiple dynamic lines across detail of report

Therat

Access Denied
Local time
Today, 23:27
Joined
May 21, 2002
Messages
53
I am a self taught VB newbie. I found code for a single line to be dynamically drawn from the Microsoft Website. Can someone help me with the code for multiple lines. I need a line on the far left of the report, in the middle, and on the end. Thanks!

//Single line code//
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim X1 As Single, Y1 As Single
Dim X2 As Single, Y2 As Single
Dim Color As Long

' Specify unit of measurement for coordinates on a page...
Me.ScaleMode = 5 ' Specify that measurement occur in inches.

' Set line to print 5 inches from the left margin.
X1 = 4
X2 = 4

' Set line to print from the top of the detail section
' to a maximum height of 22 inches.
Y1 = 0
Y2 = 22
Me.DrawWidth = 2 ' Width of the line (in pixels).
Color = RGB(0, 0, 0) ' Use black line color.

' Draw the line with the Line method.
Me.Line (X1, Y1)-(X2, Y2), Color
End Sub


Thanks,
TheRat
 
G’day TheRat

This is about as simple as I can make it without seeing the Report.
(To me, Reports are a very visual thing and each one needs ‘tuning’, particularly the margins.)

Code:
Option Explicit
Option Compare Text


Private Sub Detail_Print(ByRef intCancel As Integer, _
                         ByRef intPrintCount As Integer)
                         
    DrawLines 3

End Sub


Private Sub DrawLines(ByVal lngNumLines As Long)
    Dim lngColour As Long
    Dim sngLeft   As Single

    [color=green]'   Make color Black.[/color]
    lngColour = vbBlack
    
    [color=green]'   Minimum of two lines (left and right)... protect against division by zero.[/color]
    For sngLeft = 0 To Me.Width Step Me.Width / (IIf(lngNumLines < 2, 1, lngNumLines - 1))
        Me.Line (sngLeft, 0)-(sngLeft, Me.Detail.Height), lngColour
    Next sngLeft
    
End Sub
Hope that is something to 'tune'.

Regards,
Chris.
 
How about a horizontal line at the bottom of report?

I got code to work for vert lines, but I need a horizontal line across the bottom of my report. My problem? My detail section of the report has two different columns and can dynamically grow at different lengths. See a small pic of my report. Can someone add code for drawing a horizontal line? I tried unsuccessfully to get it to work!

Here the code I got to work with vert lines:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me.ScaleMode = 1
Me.DrawWidth = 2 ' Width of the line (in pixels)
Me.ForeColor = 0
'Repeat the following line of code for each vertical line
' 1*1440 represents 1 inch
Me.Line (0 * 1440, 0)-(0 * 1440, 14400) 'Draws line at Left Margin
Me.Line (4 * 1440, 0)-(4 * 1440, 14400) 'At 4 inch
Me.Line (8 * 1440, 0)-(8 * 1440, 14400) 'At 8 inch
Me.Line (9.46 * 1440, 0)-(9.46 * 1440, 14400) 'At 9.46 inch
Me.Line (0 * 1440, 14400)-(9.46 * 1440, 14400) 'my attempt at horiz. line

'the 14400 is an arbitrary number to increase the line to the max of a
'section.
End Sub

Thanks in advance,
TheRat
 

Attachments

  • report pic.JPG
    report pic.JPG
    20.3 KB · Views: 340
Last edited:
G’day TheRat

Try going into report design view and draw the line at the bottom on the detail section.
As the text boxes grow and shrink they should drag the line with them.

Hope that helps.

Regards,
Chris.
 

Attachments

Last edited:
Thanks Chris!

I appreciate the time you've taken to answer my questions! However, I can't get your code to work for my horizontal line. Can you please review my example? Focus on the Employee report, not the rest of the gunk in the attached database. I want a horizontal line to close of the bottom of each page. My current report doesn't work when a grouped section spans across two pages. I don't really want lines across each record. Any insight?

Thanks in advance,
TheRat
 

Attachments

Last edited:
Me.Line (0 * 1440, 14400)-(9.46 * 1440, 14400) 'my attempt at horiz. line

I think your Y coordinates are outside the area of the report that's being printed. Try:

Code:
Me.Line (0, Me.Height)-(9.46 * 1440, Me.Height)

hth,

Doug.
 
Looks like Doug’s reply should work but sure, can you convert it back to A97 please.

Edit to add.
You could also try placing the line in the Page Footer as well.

Regards,
Chris.
 
Last edited:
Not quite there...

The code given on a previous thread: Me.Line (0, Me.Height)-(9.46 * 1440, Me.Height) creates a pretty horizontal line on every record. However, I am trying to avoid putting a line across the bottom of each record. I only want to cap off the bottom of each page. As I said previously, my current report doesn't work when a grouped section spans across two pages. See the Employee Report in the attached database. Any other insight?

:confused:

I've attached an Access97 version.

Thanks in advance,
TheRat
 

Attachments

Whew! Zipped file just made it under...

Look at "testing 01" in reports and tell me if that's what you want it to do. "testing 01" is a copy of 01 WeeklyReport-Employee (and has a tricky bit of code behind it, if I do say so myself).
 

Attachments

He shoots... he scores! Thanks to all for responding.

I love this site.

:cool:

Thanks again,
The Rat
 

Users who are viewing this thread

Back
Top Bottom