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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drawing a line using code

Status
Not open for further replies.

Aubs010

Technical User
Apr 4, 2003
306
GB
How can I draw a horizontal line using code?

I have the following that puts the Reference and Element details into the report, but it's a horizontal line that I want...
Code:
    If Right(Me.Ref.Value, 2) = "zz" Then
        Me.FontBold = True
        Me.CurrentX = 200
        Me.CurrentY = 500
        Me.Print (Left(Me.Ref.Value, 1))
        Me.CurrentX = 800 - 0
        Me.CurrentY = 500 - 0
        Me.Print (Element)
    End If
I've looked at:
expression.Line(flags, x1, y1, x2, y2, color)

and the example:

Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    ' Call the Drawline procedure
    DrawLine
End Sub

Sub DrawLine()
    Dim rpt As Report, lngColor As Long
    Dim sngTop As Single, sngLeft As Single
    Dim sngWidth As Single, sngHeight As Single

    Set rpt = Reports!EmployeeReport
    ' Set scale to pixels.
    rpt.ScaleMode = 3
    ' Top inside edge.
    sngTop = rpt.ScaleTop + 5
    ' Left inside edge.
    sngLeft = rpt.ScaleLeft + 5
    ' Width inside edge.
    sngWidth = rpt.ScaleWidth - 10
    ' Height inside edge.
    sngHeight = rpt.ScaleHeight - 10
    ' Make color red.
    lngColor = RGB(255,0,0)
    ' Draw line as a box.
    rpt.Line(sngTop, sngLeft) - (sngWidth, sngHeight), lngColor, BEnd Sub

From that, I put this into the if statement (which works!)above:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If Right(Me.Ref.Value, 2) = "zz" Then
        Me.FontBold = True
        Me.CurrentX = 200
        Me.CurrentY = 500
        Me.Print (Left(Me.Ref.Value, 1))
        Me.CurrentX = 800 - 0
        Me.CurrentY = 500 - 0
        Me.Print (Element)

    Dim rpt As Report, lngColor As Long
    Dim sngTop As Single, sngLeft As Single
    Dim sngWidth As Single, sngHeight As Single

    Set rpt = Reports!EmployeeReport
    ' Set scale to pixels.
    rpt.ScaleMode = 3
    ' Top inside edge.
    sngTop = rpt.ScaleTop + 5
    ' Left inside edge.
    sngLeft = rpt.ScaleLeft + 5
    ' Width inside edge.
    sngWidth = rpt.ScaleWidth - 10
    ' Height inside edge.
    sngHeight = rpt.ScaleHeight - 10
    ' Make color red.
    lngColor = RGB(255, 0, 0)
    ' Draw line as a box.
    rpt.Line (sngTop, sngLeft)-(sngWidth, sngHeight), lngColor, B
    
    End If
End Sub

It doesn't let me preview the report. it flashes and goes back into the design view.

I also tried changing the line:
Code:
    rpt.Line (s
into
Code:
    Me.Line (s

same thing happens...


Any help would be appreciated :)


Aubs
 
okay, I got it!!

Code:
    Dim TopLineTop As Single, TopLineLeft As Single
    Dim TopLineWidth As Single, TopLineHeight As Single

    TopLineTop = 0
    TopLineLeft = 0
    TopLineWidth = 11000
    TopLineHeight = 10
    TopLineColor = RGB(0, 0, 0)
    Me.DrawWidth = 10
    Me.Line (TopLineTop, TopLineLeft)-(TopLineWidth, TopLineHeight), TopLineColor, B


Aubs
 
okay, I've got it to insert a line where I need it. Now is a different question...

How can I insert a line at the end of a record ONLY IF that record is the last record on the page?

i.e. every record that is the last record on a page...?


Aubs
 
ok, Rephrased the question...!

How can I insert a black line at the bottom of the last record on each page?

Every record that is the last record on a page needs to have a line under it
Code:
 __________________
|  Report Header   |
|   Page Header    |
|     Record1      |
|     Record2      |
|     Record3      |
|     Record4      |
|     Record5      |
|     Record6      |
|     Record7      |
|     Record8      |
|
[tt]-----[/tt]
Code:
       |
|   Page Footer    |
|  Report Footer   |
|__________________|
It CAN NOT be in the footer as on some pages the last record is not as close to the footer as on other pages

I can draw a horisontal line using the following code:
Code:
    Dim TopLineTop As Single, TopLineLeft As Single
    Dim TopLineWidth As Single, TopLineHeight As Single

    TopLineTop = 0
    TopLineLeft = 0
    TopLineWidth = 11010
    TopLineHeight = 10
    TopLineColor = RGB(0, 0, 0)
    Me.DrawWidth = 5
    Me.Line (TopLineTop, TopLineLeft)-(TopLineWidth, TopLineHeight), TopLineColor, B
    Me.DrawWidth = 0

Any help greatly appreciated.


Aubs
 
Please please can someone have a look at this and see if they can answer it! I can't do anything more at the moment until I get this right, because if I can't do it, I'll have to re-think quite a bit!!

Poor me!!!!

If anyone does have a comment, please let me know, even if it is to say that it is impossible or that it would take a LOT of coding!

Thanks in anticipation,


Aubs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top