Results 1 to 6 of 6
  1. #1
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188

    Drawing a rectangle around detail and footer

    I know diddly about VB. I found the below sample code that appears to do what I need. I need to draw a rectangle around a report detail section and page footer. It does do it, but I'm having issues trying to modify.

    How should I be using the DrawWidth property to set the rectangle line width? I'm looking to set it a 2 pts, but would like finer control if possible.

    Please explain this...
    sngTop = rpt.ScaleTop + 0 seems to do nothing to set the top location of the rectangle, and appears to be adjusting the left side.


    sngLeft = rpt.ScaleLeft + 2 seems to be setting the top dimension of the rectangle and nothing to do with the left location
    What am I missing?

    Code:
    Private Sub Report_Page()
        Dim rpt As Report, lngColor As Long
        Dim sngTop As Single, sngLeft As Single
        Dim sngWidth As Single, sngHeight As Single
        Dim sngLineThickness As Single
        Set rpt = Reports!ReportName
        ' Set scale to 0 for pixels, 5 for inches
        rpt.ScaleMode = 5
        ' Top inside edge.
        sngTop = rpt.ScaleTop + 0
        ' Left inside edge.
        sngLeft = rpt.ScaleLeft + 2
        ' Width inside edge.
        sngWidth = rpt.ScaleWidth + 0
        ' Height inside edge.
        sngHeight = rpt.ScaleHeight + 0
        ' Make color red.
        lngColor = RGB(255, 0, 0)
        ' Set line thickness
        sngLineThickness = rpt.DrawWidth + 2
        ' Draw line as a box.
        rpt.Line (sngTop, sngLeft)-(sngWidth, sngHeight), lngColor, B
    End Sub
    Thanks!

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Code:
    rpt.Line (sngLeft, sngTop)-(sngWidth, sngHeight), lngColor, B
    You need to reverse these like above.
    I played with line thickness, using rpt.drawmode, rpt.drawstyle in the on_print event of the detail section and got nowhere.
    Last edited by davegri; 05-01-2019 at 10:05 PM. Reason: format

  3. #3
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    Thanks for clearing up the top and left coordinates. I've been searching for examples of DrawWidth use and cannot find a solution. If any has suggestions for DrawWidth, I'm all ears.

    Code:
    Private Sub Report_Page()
        Dim rpt As Report, lngColor As Long
        Dim sngTop As Single, sngLeft As Single
        Dim sngWidth As Single, sngHeight As Single
        Set rpt = Reports!ReportName
        ' Set scale to 0 for pixels, 5 for inches
        rpt.ScaleMode = 5
        ' Top inside edge.
        sngTop = rpt.ScaleTop + 2
        ' Left inside edge.
        sngLeft = rpt.ScaleLeft + 0
        ' Width inside edge.
        sngWidth = rpt.ScaleWidth + 0
        ' Height inside edge.
        sngHeight = rpt.ScaleHeight + 0
        ' Make color red.
        lngColor = RGB(255, 0, 0)
        ' Set line thickness
        rpt.DrawWidth = 3
        ' Draw line as a box.
        rpt.Line (sngLeft, sngTop)-(sngWidth, sngHeight), lngColor, B
    End Sub
    thanks!

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Code:
    rpt.DrawWidth = 30
    ' Draw line as a box. rpt.Line (sngLeft, sngTop)-(sngWidth, sngHeight), lngColor, B
    This seems to work. Apparently it's in pixels, not points.
    Last edited by davegri; 05-02-2019 at 08:53 AM. Reason: format

  5. #5
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    rpt.DrawWidth = 50 worked for me. It closer resembles the 3pt lines I created in design mode.

    Very much appreciated!
    Thanks!

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Glad to help. It's an interesting form treatment that I never knew existed, so we both learned something.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 11-17-2015, 05:49 PM
  2. space between Detail and Footer
    By ConfusedMike in forum Reports
    Replies: 5
    Last Post: 11-17-2015, 05:46 PM
  3. Replies: 1
    Last Post: 08-08-2014, 04:29 PM
  4. Replies: 1
    Last Post: 04-14-2013, 07:01 PM
  5. Replies: 1
    Last Post: 02-18-2013, 02:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums