Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add designated # of horizontal lines in report

Status
Not open for further replies.

DLynnTX

IS-IT--Management
Dec 9, 2004
67
US
I am trying to create a report for customer orders. There will be a different # of items each time it is used. However, they want to have horizontal lines that go down the right side of the report from where the data starts to the bottom of the page no matter how many items are printing. How can I do that?
 
U can search on GReen Bar Effect... here is some onld posts... htwh,

+++++++++++++++++++++++++++

MS Access Reports - SMedvid

This will give a green bar effect on a report. Every other line green. You may want to play around with the numeric color expressions if you don't like the loud green you get from vbGreen. Just a tip...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.Detail.BackColor = vbWhite Then
Me.Detail.BackColor = vbGreen
Else
Me.Detail.BackColor = vbWhite
End If

End Sub



MichaelRed (Programmer) Jul 12, 2004
Somewhat easier:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

'Michael Red. 2/13/2002. To 'Toggle the backolor, which
'Provides alternate line shading
Const XorToggle = 4144959

Me.Detail.BackColor = Me.Detail.BackColor Xor XorToggle

End Sub

Of course, the const used in this provides a light grey, but you can use a different constanta and get any color desired.


Steve Medvid
"IT Consultant & Web Master"

Chester County, PA Residents
Please Show Your Support...
 
I tried this and it still only shades the lines that are actually being used for data (i.e. if there are two items, then it shades one and leaves the other white; if there are 3, it shades two and leaves 1). I need it to have lines all the way down the page no matter how many items are used. Any suggestions?
 
You may need to create group footer and move your detail line code into that section. Then try to put the code there? htwh,


Steve Medvid
"IT Consultant & Web Master"

Chester County, PA Residents
Please Show Your Support...
 
If this is a repeat, I apologize - I tried to reply and my screen went blank.

I created a group footer and moved my detail info into that section. Then I clicked on the footer and added the code for the shading (it put it in the OnFormat section). It didn't change anything. What am I doing wrong? Thank you for your help.
 
In your report’s PageHead Section place the following code:

Private Sub PageHeader_Format(Cancel As Integer, FormatCount As Integer)
Me.MoveLayout = False
End Sub

Make the PageHead Section about 9 inches in height. Draw horizontal lines about 4 per inch. Adjust this to height of the Detail Section.

This is the same as a Watermark for a report. In this case, your lines are the Watermark.

This should get you into the ballpark then adjust to your needs.
 
StarPassing, I couldn't get this to work (I'm assuming because of the info I already had in the PageHeader and the info I didn't want repeated). Anyway... I ended up just putting a set # of lines in the detail section and only printing two items per page so that they would have enough lines. Thank you anyway.

 
Use code in the On Page event of your report. The Line method allows you to create lines anywhere you want on the report. You can use the following code as a sample. It draws 20 horizontal lines which can easily be changed.
Code:
Private Sub Report_Page()
    Dim intNumLines As Integer
    Dim intLineNumber As Integer
    Dim intTopMargin As Integer
    Dim ctl As Control
    Dim intLineHeight As Integer
    Dim intLineLeft As Integer
    Dim intLineWidth As Integer
    intNumLines = 20
    intLineLeft = 720 '1/2 inch from left margin
    intLineWidth = 1440 * 5 '5 inches
    intTopMargin = Me.Section(3).Height
    intLineHeight = Me.Section(0).Height
    For intLineNumber = 0 To intNumLines - 1
        Me.Line (intLineLeft, intTopMargin + _
            (intLineNumber * intLineHeight)) _
            -Step(intLineWidth, 0)
    Next
End Sub

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I get a run-time error '6' when I use this code. Now, I know NOTHING about code, so all I did was copy and paste it and put it as the On page event of the report. Not sure where to go from here. Sorry...
 
If you don't have a Page Header section, then remove this line:
[blue][tt] intTopMargin = Me.Section(3).Height[/tt][/blue]
Me.Section(3) is the Page Header.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top