[AccessD] Variable line height

A.D.Tejpal adtp at airtelmail.in
Thu Apr 23 00:35:59 CDT 2009


Rocky,

    You can draw a vertical line spanning entire detail section by using the Line() method. Sample code in detail section's print event, as given below, will draw the desired vertical line between text boxes named Txt_1 & Txt_2.

    As long as the Y coordinate is set greater than dynamic height of detail section, the line will automatically fit into the available space, eliminating the scope for any possible breaks.

    For further refinements in drawing vertical and horizontal lines on a report in various styles, my sample db named  ReportBorders  might be of interest to you. It is available at Rogers Access Library. Link - 

http://www.rogersaccesslibrary.com/forum/forum_topics.asp?FID=45
 
    You could adapt the underlying approach suitably, for your specific needs.


Best wishes,
A.D. Tejpal
------------

' Code in report's module
' (Txt_1 & Txt_2 are the names of text boxes 
' between which a vertical line is to be drawn)
'==================================
Private Sub Detail_Print(Cancel As Integer, _
                                PrintCount As Integer)
    Dim X As Long, Y As Long
    Dim GapLeft As Long, GapWidth As Long
    
    Me.ScaleMode = 1    ' Scale in Twips
    Me.DrawWidth = 3    ' Thickness in pixels
    
    ' Set the X value midway between the two
    ' text boxes (Txt_1 & Txt_2)
    GapLeft = Me.Txt_1.Left + Me.Txt_1.Width
    GapWidth = Me.Txt_2.Left - GapLeft
    X = GapLeft + GapWidth \ 2
    
    ' Set Y value larger than the dynamic height of
    ' Detail section. (Even if Y is set much larger
    ' than actual dynamic height of Detail section.
    ' This is to prevent any possible breaks in overall
    ' vertical line. Only the portion that can actually
    ' fit in Detail section, will get drawn)
    Y = Me.Height + 20
    
    ' Note:
    '   Me.Height gives the dynamic height of current
    '   section (in this case: detail section) at print time.
    '   Me.Detail.Height merely gives the static height
    '   of Detail section as per design setting.

    ' Draw vertical line between Txt_1 & Txt_2, so as
    ' to fully cover the dynamic height of Detail section.
    Me.Line (X, 0)-(X, Y)
End Sub
'===================================

  ----- Original Message ----- 
  From: Rocky Smolin 
  To: 'Access Developers discussion and problem solving' 
  Sent: Thursday, April 23, 2009 05:41
  Subject: [AccessD] Variable line height


  Dear List:

  Client has a report with two Can Grow text boxes side by side.  He wants a
  vertical line down the middle of the report separating the two boxes. The
  two text boxes will vary in height, of course, depending on the data. How
  can the height of the line be set to run vertically down the full length of
  the detail section of the report where these two boxes are.  You can't
  change the height of the line in the Print event, and the height of the box
  is apparently not yet set (per a MsgBox I inserted) in the Format event? 

  MTIA 

  Rocky


More information about the AccessD mailing list