Make a Vertical Line the Same Height as a CanGrow/CanShrink Control
Problem
You have a control on a report that has its CanShrink and CanGrow properties set to Yes so it can grow or shrink to accommodate different amounts of text. You placed a vertical line to the left of the control, and you want it to be the same height as the control. Is there a way you can synchronize the height of the two controls?
Solution
If you place a line on a report using the Line tool, it will always be the same size. To make a line change its height to match the height of another control (or group of controls), you need to use the Line method in a procedure attached to the Print event of a report section. This solution uses the Line method to make a line whose height varies to accommodate the changing height of a text box that displays a memo field.
Follow these steps to add to your own report a vertical line that shrinks or grows to match one or more CanShrink/CanGrow controls in a section:
Create a report or open an existing report in design view. Don’t use the Line control to create a vertical line in the report. If you’ve already created such a line, remove it now.
Create an event procedure for the Print event of the group footer section (or the section on your report where you’d like the line to appear). (For more information on creating event procedures, see this book’s Preface.) In the event procedure, add code similar to this:
Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As ...
Get Access Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.