[AccessD] Resize Rectangle on Report

A.D.Tejpal adtp at touchtelindia.net
Thu Jun 10 13:40:22 CDT 2004


Jim,

    Dynamic height of a control (resulting from its can grow/can shrink property) is not directly detectable in format event of the report. The status is reflected faithfully in the print event. 

    If multiple controls of this nature are positioned in vertical alignment, overall dynamic height of the group header (as returned by the height of it's parent property) is a more convenient and reliable reference. The height of rectangle enveloping these controls has to be forced accordingly (it does not have can grow/can shrink properties).

    Manipulation of a control's height is not allowed in the print event. If you are keen to display the rectangle mentioned by you, the following course of action is suggested -

    (a) In the first run, use a global array to capture the dynamic heights of group header during the print event. Put a control serving as overall counter for the group header. This will help in providing index numbers for different elements of the array. (The report has to be navigated right upto the last page in print-preview, so as to ensure that all the values get assigned to the array).

    (b) In the second run, set the height of rectangle as per relevant element of the array.

    (c) Put suitable code in click event of command button on a form so as to ensure that the report is opened in two stages as per (a) & (b) above. Setting of a global variable will ensure that only the appropriate action is taken, depending upon whether it is the first run or otherwise.

    Necessary code is given below. If at any stage, you happen to need further assistance , a sample file demonstrating this technique can be sent to you.

Regards,
A.D.Tejpal
--------------
============================
General Module -
----------------------
Public BoxHt() As Integer  ' Global array
Public FirstRun As String   ' ("Y" for first run of the report)

Report Module (BoxHdr is the name of rectangle, TxtHdrCount is the name of counter control) -
-------------------------------------
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
    If FirstRun = "N" Then
        BoxHdr.Height = BoxHt(TxtHdrCount)
    End If
End Sub

Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
    If FirstRun = "Y" Then
        ReDim Preserve BoxHt(TxtHdrCount + 1)
        BoxHt(TxtHdrCount) = GroupHeader0.Parent.Height - 5
    End If
End Sub

Private Sub Report_Open(Cancel As Integer)
    If FirstRun = "Y" Then
        ReDim BoxHt(1)   ' Initialize the array
    End If
End Sub

Form Module (R_Box is the name of report, CmdReport is the name of command button) -
--------------------------------------------------------
Private Sub CmdReport_Click()
    FirstRun = "Y"
    DoCmd.OpenReport "R_Box", acViewPreview
    DoCmd.RunCommand acCmdFitToWindow
    SendKeys "^{DOWN}", True   ' For going to last page
    DoCmd.Close acReport, "R_Box", acSaveYes
    
    FirstRun = "N"
    DoCmd.OpenReport "R_Box", acViewPreview
    DoCmd.RunCommand acCmdZoom100
End Sub
============================
  ----- Original Message ----- 
  From: Scott Marcus 
  To: Access Developers discussion and problem solving 
  Sent: Wednesday, June 09, 2004 22:55
  Subject: RE: [AccessD] Resize Rectangle on Report


  Just make a textbox look like a rectangle where the foreground equals the background (making its text invisible), set its control source to the same as the other control, and then set it to can grow. 
  Scott Marcus
  TSS Technologies, Inc.
  marcus at tsstech.com
  (513) 772-7000

   -----Original Message-----
  From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]  On Behalf Of Rocky Smolin - Beach Access Software
  Sent: Wednesday, June 09, 2004 1:17 PM
  To: Access Developers discussion and problem solving
  Subject: Re: [AccessD] Resize Rectangle on Report

  Jim:

  Probably not very satisfactory but could you make the label invisible and
  add the label caption to the text box - control source of the text box to
  =lbl.Caption & vbcrlf & vbcrlf & fldRegularControlSource so that the label
  would be inside the text box?

  Rocky

  ----- Original Message ----- 
  From: "Jim Hewson" <JHewson at karta.com>
  To: "Access Developers discussion and problem solving"
  <accessd at databaseadvisors.com>
  Sent: Wednesday, June 09, 2004 10:01 AM
  Subject: RE: [AccessD] Resize Rectangle on Report
  >
  > This didn't work either.
  >
  > -----Original Message-----
  > From: accessd-bounces at databaseadvisors.com
  > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Jim Hewson
  > Sent: Wednesday, June 09, 2004 11:27 AM
  > To: Access Developers discussion and problem solving
  > Subject: RE: [AccessD] Resize Rectangle on Report>
  >
  > My problem is the label and text box is located inside the rectangle.
  > If I make the border of the text box visible the label isn't included in
  the "visible box"
  > I wonder if the border of label would work?
  > I'll try it.
  > Thanks,
  > Jim
  >
  > -----Original Message-----
  > From: accessd-bounces at databaseadvisors.com
  > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Rocky Smolin -
  > Beach Access Software
  > Sent: Wednesday, June 09, 2004 10:38 AM
  > To: Access Developers discussion and problem solving
  > Subject: Re: [AccessD] Resize Rectangle on Report>
  >
  > Jim:
  >
  > Can you just make the border of the text box visible and drop the
  rectangle?
  >
  > Rocky
  >
  > ----- Original Message ----- 
  > From: "Jim Hewson" <JHewson at karta.com>
  > To: "AccessD" <accessD at databaseadvisors.com>
  > Sent: Wednesday, June 09, 2004 7:55 AM
  > Subject: [AccessD] Resize Rectangle on Report
  >
  > How do I resize a rectangle on a report?
  > A2K
  > I have a label and a text box inside a rectangle located in a group header. The text box is below the label and the can grow event is set to Yes.
  > Occasionally the text box grows but I can't seem to make the rectangle grow with it.
  > How can I make it grow?
  >
  > Thanks,
  >
  > Jim




More information about the AccessD mailing list