Hi All , it is my first post in this great forume ,

I am in a greate problem and i hope to find the solurion here ,
I created a datareport and used the (shape) object as a frame for each row in the report ,
my case is when the RptTextBox is grown "as its can grow property is set to true" the shape is not growing , i tried using the code , but still the same ,
the code i set is:

rptname.sections("DetailsSection").controls("shape").height=rptname.sections("DetailsSection").height

Dani AI

Generated

Short answer: the shape does not auto-resize when a textbox with CanGrow expands. The report engine grows the textbox during layout, but it does not automatically resize other controls to match. Instead, resize the shape at the time the section is formatted so it uses the textbox's actual (post-grow) height.

A practical approach is to adjust the shape in the Details section's format handler so its Top/Height follow the textbox (add a small padding). Example pattern:

Private Sub DataReport_Details_Format()
    Dim txtH As Long
    txtH = Me.Sections("Details").Controls("txtLongText").Height
    Me.Sections("Details").Controls("shFrame").Height = txtH + 144  ' 144 twips = 0.1 inch padding
    Me.Sections("Details").Controls("shFrame").Top = _
        Me.Sections("Details").Controls("txtLongText").Top - 72   ' optional top padding
End Sub

Troubleshooting tips:

  • Heights/positions are in twips (1440 twips = 1 inch). Add a few twips of padding so the border does not overlap text.
  • Use the textbox Height (not the section Height) because section Height often reflects design-time size.
  • Make sure the shape is behind the textbox in Z-order so text stays readable.
  • If you cannot get reliable results at format time, compute the required height before the report runs (Printer.TextWidth/TextHeight or Win32 DrawText with DT_CALCRECT) and set control sizes programmatically, or replace the single Shape with adjustable line/box parts (top/bottom/side lines) or use textbox borders to simulate a frame.

As suggested, shapes don't automatically follow content size — resizing in the section-format step is the reliable fix.

Recommended Answers

All 2 Replies

hi. i think it will only grow when the data transfers to the object is longer than the object's current width. it will automatically adjust as the data or text gets longer.

thank you for your reply ,
yah I know that the textbox will grow , but what i need to resize if the shape arround the record ,
the section and the textboxes are doing fine , however the shape stills at the original size no matter what is the section size,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.