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!

Changing Rectangle Width (per record) On A Report 1

Status
Not open for further replies.

dapotter

Programmer
Oct 9, 2004
32
US
I want to create a report on which a rectangle will be drawn for each record. The length of the record should be based on a numeric field from that record. Specifically, I would like two rectangles, one to serve as a border and one as a fill. They would work together as a chart.

For example, I might have a report to show progress toward a list of savings goals (each record representing one goal). The underlying table might have fields of goal and received. I could simply include an edit box that shows (received / goal) * 100 as text, but I'd like to give a graphical representation as well.

I assume I will need to access the rectangle properties through VBA (which is why I'm posting here, and not in the Microsoft: Acess Reports forum). But I don't know how to get the set of currently displayed records. Does anyone have an example showing how to do this?

There are probably solutions to my problem that are superior to the approach I'm trying to take. I'd be grateful to learn about any of these.

Thanks for your help,
Don
 
The code below is copied from Microsoft Help, with the simple subsitution of a field for one of the values.

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(Me.Name)
    ' 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 = [red]Me.Code * 100[/red] '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 Sub
 
Thanks Remou!

That was a lot easier than I expected, which probably means I should have worked harder to find it myself. But I greatly appreciate your help.

Don
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top