Predicting the height of a CanGrow text box

L

Lee

Anyone know an efficient way to predict how high data will be when written
to a CanGrow text box?

*Alternately* Anyone know an efficient way to force Print events on a report
without actually printing the report?

*Alternately* Anyone know an accurate and efficient way to word-wrap text to
a given width in inches? (The text would be printed in a variable-width
font.)

I am working with XP, but must support Access 97.

I have a situation where I am using a CanGrow text box in a CanGrow detail
section, but I need the height of each detail section to match the height of
the tallest detail section on the report.

(i.e. If the tallest record is 3 lines high, I want all records 3 lines
high. If the tallest is 1 line high, I want all to be 1 line high.)

The best I have come up with is to make a dry run with the report using
CanGrow detail sections, and record the height of the highest detail
section. Then I would restart the report, this time fixing the height of
the detail section on startup.

This would work OK for me, but from what I can tell the CanGrow object's
final height can only be read in the Print event. The print events do get
triggered on a report Preview, but only for the records on the first page of
the report, so I would need to find a way trick Access into Previewing each
page of the report.

My fallback is to ignore the CanGrow feature altogether and word-wrap the
data myself before printing the report. Then I can fix the height of the
detail section to match the data I have already prepared. But considering
the data will be printed using variable-width fonts, I am not in a rush to
do the wrapping myself.

Thanks!
Lee
 
M

Marshall Barton

Lee said:
Anyone know an efficient way to predict how high data will be when written
to a CanGrow text box? []

I am working with XP, but must support Access 97.

I have a situation where I am using a CanGrow text box in a CanGrow detail
section, but I need the height of each detail section to match the height of
the tallest detail section on the report.

(i.e. If the tallest record is 3 lines high, I want all records 3 lines
high. If the tallest is 1 line high, I want all to be 1 line high.)

The best I have come up with is to make a dry run with the report using
CanGrow detail sections, and record the height of the highest detail
section. Then I would restart the report, this time fixing the height of
the detail section on startup.

This would work OK for me, but from what I can tell the CanGrow object's
final height can only be read in the Print event. The print events do get
triggered on a report Preview, but only for the records on the first page of
the report, so I would need to find a way trick Access into Previewing each
page of the report.

Tough problem! If you know the Width of the text box before
you run the report, then you could run a query (with the
same criteria as the report's record source query) that uses
Stephen Lebans' TextHeight function (www.lebans.com) to
calculate the Max TextHeight of the field.

If you don't know the text box's Width, then you will have
to at least open the report, retrieve the text box's Width
and the run the query to calculate the Max TextHeight.
 
L

Lee

Marsh,

Those functions are perfect, exactly the ones I didn't want to have to write
myself <Grin>

Thanks!
-- Lee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top