Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Location
    Nashville, Tennessee, USA
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Drawing a line (Access97)

    The below code was used to "Shade" a column in a report by drawing an extremly wide line. When used in other reports Y12 has been set to 22 (Simply because it is unpratical at this point for a single item to continue for that long, therefore I know the shading will cover the entire detail). However, now that I would like to change this so that it can be used in the footer, it needs to be changed to approx .25 inches, empty space between the group footer and the next group header. That is the problem.

    Can anyone explain why the line appears to start to / towards the bottom when the length is shortened? Why won't it simply stop flat at the bottom? Any suggestions?


    Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)
    Dim X11 As Single, Y11 As Single
    Dim X12 As Single, Y12 As Single


    Dim Color1 As Long

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

    ' Set line to print 3.23 inches from the left margin.
    X11 = 3.23
    X12 = 3.23



    ' Set line to print from the top of the detail section
    ' to a maximum height of .25 inches.
    Y11 = 0
    Y12 = 0.25

    Me.DrawWidth = 360


    Color1 = 12632256

    ' Draw the line with the Line method.
    Me.Line (X11, Y11)-(X12, Y12), Color1
    End Sub


    First it has been suggested to keep the line small, but how small? Because in total they need to be the same width as mentioned above.

    Then, it was suggested to simply use backcolor and I tried, however the results where not good at all.
    I can not simply backcolor the field with the color because the detail width varies since the field [Desc] is set to can grow to make sure the entire field is shown. If the Backcolor is used it will not make a continueous shade of the column, it breaks.
    (I.E.)Y1sum is the column that needs to be shaded (All Ysum's have dollar amounts, Y1Sum amounts left off to show shading if backcolor only used)
    Item Description Y1Sum Y2Sum Y3Sum
    1 kljlkfjalkfjlkajfl shaded 1000 5000
    dlfkjalfjafja;ljak;l no shade
    jklfjalkfjlajfla;jf no shade
    dlkajflkajklfjalkfjlkdaj no shade
    2 jflkajflkjalkfj Shaded 2500 7500
    jkflajlfjalfjlakjlk no shade
    3 jfklajflkajflkajlkfjl Shaded 500 0
    klfjalkfjal no shade
    4 ffkafkljaklfjlkafjkla Shaded 1500
    5 kjjaklfjakldfjklajfklj Shaded 25 222
    6 jfkljalkfjalkfjlakjflkja Shaded 999 2588
    jkdlajlfkjalkfjalkfj no shade
    fkjalkfjalkjflajlfjal no shade

    Unless there is away to have [Y1Sum]'s width = the width of [Desc]?
    The above is an example of when there is a large grouping, and the line works. However what I need to do is sort and group differently and need to have a group footer that as shadding of only .25
    Any suggestions?

  2. #2
    New Lounger
    Join Date
    Nov 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drawing a line (Access97)

    My solution (sorry if it won't work for you) was to use the line routine to draw a BOX not line. After all, that's the goal. Change X12 to X11 + line width and use BF after line. This worked in Access 97.

    I remember something about line drawing routines being flakey a long time ago and this kind of stirred my memory.


    Private Sub PageFooter_Format(Cancel As Integer, FormatCount As Integer)
    Dim X11 As Single, Y11 As Single
    Dim X12 As Single, Y12 As Single


    Dim Color1 As Long

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

    ' Set line to print 3.23 inches from the left margin.
    X11 = 3.23
    X12 = 3.5
    '


    ' Set line to print from the top of the detail section
    ' to a maximum height of .25 inches.
    Y11 = 0
    Y12 = 0.25

    Me.DrawWidth = 360


    Color1 = 12632256

    ' Draw the line with the Line method.
    Me.Line (X11, Y11)-(X12, Y12), Color1, BF
    End Sub

  3. #3
    Star Lounger
    Join Date
    Oct 2003
    Location
    Nashville, Tennessee, USA
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drawing a line (Access97)

    That is PERFECT for how I needed to format in the group footer!!!!!!! I mean PERFECT!!!! All I had to do was to work with the numbers to get it in the right spot and width.
    Not to mention, "redo" that part in all the other reports where I "worked" around it.

    As a side question, do you know how to draw a horizontal line in code? I have tried and tried to work with the existing lines, but the will not allow me to tell them exactly where to go (I.E. 4.62 would round to something link 3.8 or 4.69) And with these reports going up the chain, the lines not meeting does not look too good on my behalf.

  4. #4
    New Lounger
    Join Date
    Nov 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drawing a line (Access97)

    The rounding problem is probably due to the Microsoft's use of "TWIPS" as a basic unit of measure: 1440 TWIPs per inch. I create some reports through code, and to populate them with lines, text boxes, etc use following function:

    CreateReportControl()

    For that function, under the "left, top" field explanation in Help, is a quick blurb about "twips".

    And rather than fight with it I just standardized on some basic, simple measurements. I even made some constants like this to prevent myself from worrying about any rounding Access does:

    ' 1440 TWIPS per inch
    Const TwentiethInch = 1440 * 0.05
    Const FifthInch = 1440 * 0.2
    Const HalfInch = 1440 * 0.5
    Const Inch = 1440
    Const QuarterInch = 1440 * 0.25
    Const SixteenthInch = 1440 * 0.0625
    Const TenthInch = 1440 * 0.1
    Const ThirdInch = 1440 * 0.333
    Const ThreeQuarterInch = 1440 * 0.75

    And used them in the code. Took more typing, but then when I changed things I could read my code easier weeks later when I'd forgotten things...

    For manually designed reports, in design mode, to align anything, I select one item, hold SHIFT down and select the others, then change the desired left/right to a common value. Doesn't stop Access from rounding my input to the TWIP equivilent, but does align rows or columns of objects.

    Someone else may have a better way of dealing with this.

  5. #5
    Star Lounger
    Join Date
    Oct 2003
    Location
    Nashville, Tennessee, USA
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drawing a line (Access97)

    So this means that there is no way to manipulate the code for a vertical line to result in a horizontal line? If so, where would the control go, and how is it used? Is it simply for a "Reminder" on how may TWIPS per inch/half inch, etc?

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drawing a line (Access97)

    You would put the declared constants into a standard module and make each declaration PUBLIC if you want to use it throughout the application. If it's a one-off use, put them in the form module in the Declarations section. Then in your code itself, you can use the constant instead of its stated value to calculate positions and sized.

    A line is neither inherently vertical nor horizontal. A zero width line is vertical. A zero height line is horizontal. Every line starts out as diagonal and has a line slant property that determines the direction of the diagonal. There is no particular reason I can think of to change a line from one to the other dynamically, since doing so would require moving around a bunch of other controls.
    Charlotte

  7. #7
    New Lounger
    Join Date
    Nov 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drawing a line (Access97)

    "So this means that there is no way to manipulate the code for a vertical line to result in a horizontal line?"

    Whether a shaded "line" like the one in the code I provided is "vertical" or "horizontal" is a matter of appearance, and that depends on the value of the coordinates used. If Y coordinates are the same (or close to the same) it appears horizontal. If X coordinates are the same (or close) then it appears to be verticle.

    To draw a shaded "horizontal" line across a 6-inch section that's a quarter inch thick:

    X11 = 0
    X12 = 6

    Y11 = 0
    Y12 = .25

    Me.DrawWidth = 1

    For me, it's easier to keep track of what I'm doing when drawing a shaded area if I set the Me.DrawWidth to 1 pixel. Me.DrawWidth serves as a "border" width for unfilled boxes. For true straight lines (where X11 = X12 or Y11 = Y12), it serves as line width. For shading an area it isn't necessary to use anything but 1 and might confuse someone reading the code.

    To draw a "true" straight line one that's the thickness of the border as specified by Me.DrawWidth:

    X11 = 0
    X12 = 6

    Y11 = .25
    Y12 = .25

    Me.DrawWidth = 1
    And dropping BF from the line routine:



    Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)
    Dim X11 As Single, Y11 As Single
    Dim X12 As Single, Y12 As Single


    Dim Color1 As Long

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

    ' Set line to print 0 inches from the left margin and 6 inches wide
    X11 = 0
    X12 = 6



    ' Set line to print half inch from the section top
    Y11 = 0.5
    Y12 = 0.5

    ' line width = 1 pixel
    Me.DrawWidth = 1


    Color1 = 12632256

    ' Draw the line with the Line method.

    Me.Line (X11, Y11)-(X12, Y12), Color1
    End Sub

  8. #8
    Star Lounger
    Join Date
    Oct 2003
    Location
    Nashville, Tennessee, USA
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drawing a line (Access97)

    Is there away to tell it that I want the line to be in 3" from the left side of the paper?
    Currently Here is what I have: Now I simply need to tell the line where to go in the section (3.48" in from left side).
    Dim x1 As Single, Y1 As Single
    Dim x2 As Single, Y2 As Single
    Dim X3 As Single, Y3 As Single
    Dim X4 As Single, Y4 As Single
    Dim X5 As Single, Y5 As Single
    Dim X6 As Single, Y6 As Single
    Dim X7 As Single, Y7 As Single
    Dim X8 As Single, Y8 As Single
    Dim X9 As Single, Y9 As Single
    Dim X10 As Single, Y10 As Single
    Dim X13 As Single, Y13 As Single
    Dim X14 As Single, Y14 As Single
    Dim X15 As Single, Y15 As Single
    Dim X16 As Single, Y16 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 = 3.48 '3.48
    x2 = 3.48
    X3 = 3.98
    X4 = 3.98
    X5 = 4.48
    X6 = 4.48
    X7 = 4.98
    X8 = 4.98
    X9 = 5.48
    X10 = 5.48
    X13 = 2.98
    X14 = 2.98
    X15 = 0
    X16 = 3
    ' Set line to print from the top of the detail section
    ' to a maximum height of 22 inches.
    Y1 = 0
    Y2 = 0.21 '.21
    Y3 = 0
    Y4 = 0.21
    Y5 = 0
    Y6 = 0.21
    Y7 = 0
    Y8 = 0.21
    Y9 = 0
    Y10 = 0.21
    Y13 = 0
    Y14 = 0.21
    Y15 = 0.21
    Y16 = 0.21

    Me.DrawWidth = 10 ' 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
    Me.Line (X3, Y3)-(X4, Y4), Color
    Me.Line (X5, Y5)-(X6, Y6), Color
    Me.Line (X7, Y7)-(X8, Y8), Color
    Me.Line (X9, Y9)-(X10, Y10), Color
    Me.Line (X13, Y13)-(X14, Y14), Color
    Me.Line (X15, Y15)-(X16, Y16), Color

    End Sub


    Thank you for your help!

  9. #9
    Star Lounger
    Join Date
    Oct 2003
    Location
    Nashville, Tennessee, USA
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drawing a line (Access97)

    Please excuse my last post! I have found how to move the line and can not Thank You enough!

    Once Again, Thank You for ALL your Help!

    PBrown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •