dbTalk Databases Forums  

Adjusting height of report controls at runtime via VBA

comp.databases.ms-access comp.databases.ms-access


Discuss Adjusting height of report controls at runtime via VBA in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
brucedodds
 
Posts: n/a

Default Adjusting height of report controls at runtime via VBA - 08-31-2011 , 10:10 AM






I have an Access 2003 report with the requirement that the height of
all the controls in the detail section automatically grow or shrink to
match the height of the biggest control, a CanGrow text box. Note -
this applies to each control, not just the detail section itself.

This probably would have to happen in VBA in the OnFormat event
procedure. Does anyone have a suggestion?

TIA,

Bruce

Reply With Quote
  #2  
Old   
christianlott1@yahoo.com
 
Posts: n/a

Default Re: Adjusting height of report controls at runtime via VBA - 08-31-2011 , 10:36 AM






On Aug 31, 10:10*am, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:
Quote:
I have an Access 2003 report with the requirement that the height of
all the controls in the detail section automatically grow or shrink to
match the height of the biggest control, a CanGrow text box. *Note -
this applies to each control, not just the detail section itself.
Is selecting all controls, changing them all to CanGrow = True not
working?

I think this thing is automatic for Reports (but not forms
unfortunately).

Reply With Quote
  #3  
Old   
christianlott1@yahoo.com
 
Posts: n/a

Default Re: Adjusting height of report controls at runtime via VBA - 08-31-2011 , 10:36 AM



On Aug 31, 10:10*am, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:
Quote:
I have an Access 2003 report with the requirement that the height of
all the controls in the detail section automatically grow or shrink to
match the height of the biggest control, a CanGrow text box. *Note -
this applies to each control, not just the detail section itself.
Is selecting all controls, changing them all to CanGrow = True not
working?

I think this thing is automatic for Reports (but not forms
unfortunately).

Reply With Quote
  #4  
Old   
brucedodds
 
Posts: n/a

Default Re: Adjusting height of report controls at runtime via VBA - 08-31-2011 , 10:44 AM



On Aug 31, 11:36*am, "christianlo... (AT) yahoo (DOT) com"
<christianlo... (AT) yahoo (DOT) com> wrote:
Quote:
On Aug 31, 10:10*am, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:

I have an Access 2003 report with the requirement that the height of
all the controls in the detail section automatically grow or shrink to
match the height of the biggest control, a CanGrow text box. *Note -
this applies to each control, not just the detail section itself.

Is selecting all controls, changing them all to CanGrow = True not
working?

I think this thing is automatic for Reports (but not forms
unfortunately).
Can Grow = True will allow all controls to grow to accomodate the data
they contain. Since the data each contains will vary, they won't all
grow to the same height. These all have to grow to the same height -
that of the largest control.

Reply With Quote
  #5  
Old   
brucedodds
 
Posts: n/a

Default Re: Adjusting height of report controls at runtime via VBA - 08-31-2011 , 04:01 PM



On Aug 31, 11:10*am, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:
Quote:
I have an Access 2003 report with the requirement that the height of
all the controls in the detail section automatically grow or shrink to
match the height of the biggest control, a CanGrow text box. *Note -
this applies to each control, not just the detail section itself.

This probably would have to happen in VBA in the OnFormat event
procedure. *Does anyone have a suggestion?

TIA,

Bruce
Close but no cigar.

I found that the size of each CanGrow control in the current Detail
section is available in the OnPrint event. In the OnFormat event
it's possible to change the height of each control. Since OnPrint
executes before OnFormat, I had to run the report twice. In the first
run, OnPrint writes the maximum control height for each line to a
table. On the second run OnFormat retrieves that value and applies it
to the Height property of every control on the print line. (I used a
key value from each line as a unique identifier, but a line number
would have worked as well).

This succeeds beautifully in making each control as high as the
tallest on the line. Each line looks great. The problem is that
spacing between lines is irregular.

CanGrow is set to True for the Detail section and its controls. The
environment is Access 2007 SP2, using an Access 2003 format
database.

If anyone has any advice it would be very appreciated.

Reply With Quote
  #6  
Old   
brucedodds
 
Posts: n/a

Default Re: Adjusting height of report controls at runtime via VBA - 09-01-2011 , 05:30 AM



On Aug 31, 5:01*pm, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:
Quote:
On Aug 31, 11:10*am, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:

I have an Access 2003 report with the requirement that the height of
all the controls in the detail section automatically grow or shrink to
match the height of the biggest control, a CanGrow text box. *Note -
this applies to each control, not just the detail section itself.

This probably would have to happen in VBA in the OnFormat event
procedure. *Does anyone have a suggestion?

TIA,

Bruce

Close but no cigar.

I found that the size of each CanGrow control in the current Detail
section is available in the OnPrint event. * In the OnFormat event
it's possible to change the height of each control. * *Since OnPrint
executes before OnFormat, I had to run the report twice. *In the first
run, OnPrint writes the maximum control height for each line to a
table. *On the second run OnFormat retrieves that value and applies it
to the Height property of every control on the print line. *(I used a
key value from each line as a unique identifier, but a line number
would have worked as well).

This succeeds beautifully in making each control as high as the
tallest on the line. *Each line looks great. *The problem is that
spacing between lines is irregular.

CanGrow is set to True for the Detail section and its controls. * The
environment is Access 2007 SP2, using an Access 2003 format
database.

If anyone has any advice it would be very appreciated.
Correction - OnFormat executes before OnPrint.

Reply With Quote
  #7  
Old   
Phil
 
Posts: n/a

Default Re: Adjusting height of report controls at runtime via VBA - 09-01-2011 , 06:13 AM



On 01/09/2011 11:30:54, brucedodds wrote:
Quote:
On Aug 31, 5:01*pm, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:
On Aug 31, 11:10*am, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:

I have an Access 2003 report with the requirement that the height of
all the controls in the detail section automatically grow or shrink to
match the height of the biggest control, a CanGrow text box. *Note -
this applies to each control, not just the detail section itself.

This probably would have to happen in VBA in the OnFormat event
procedure. *Does anyone have a suggestion?

TIA,

Bruce

Close but no cigar.

I found that the size of each CanGrow control in the current Detail
section is available in the OnPrint event. * In the OnFormat event
it's possible to change the height of each control. * *Since OnPrint
executes before OnFormat, I had to run the report twice. *In the first
run, OnPrint writes the maximum control height for each line to a
table. *On the second run OnFormat retrieves that value and applies it
to the Height property of every control on the print line. *(I used a
key value from each line as a unique identifier, but a line number
would have worked as well).

This succeeds beautifully in making each control as high as the
tallest on the line. *Each line looks great. *The problem is that
spacing between lines is irregular.

CanGrow is set to True for the Detail section and its controls. * The
environment is Access 2007 SP2, using an Access 2003 format
database.

If anyone has any advice it would be very appreciated.

Correction - OnFormat executes before OnPrint.


Guessing
OK before we start, set all the control's Tags to 0
Scan all the controls in the report where the Tag is 0 and find the Lowest
value of the .Top position of each one and the height, so giving the bottom
of the control. Let's call this CtlA
Then find all the controls where the .Top is between the .Top and bottom of
CtlA and set the .Top = .Top(CltA), and set the Tag to +No of loops you have
gone through. So on the next scan through, the .Top will be set to the
(.)Bottom of the previous row + a suitable gap. Finish the loop when there
are no more tags = 0 Phil

Reply With Quote
  #8  
Old   
brucedodds
 
Posts: n/a

Default Re: Adjusting height of report controls at runtime via VBA - 09-01-2011 , 07:19 AM



On Sep 1, 7:13*am, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:
Quote:
On 01/09/2011 11:30:54, brucedodds wrote:









On Aug 31, 5:01*pm, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:
On Aug 31, 11:10*am, brucedodds <brucedo... (AT) comcast (DOT) net> wrote:

I have an Access 2003 report with the requirement that the height of
all the controls in the detail section automatically grow or shrink to
match the height of the biggest control, a CanGrow text box. *Note-
this applies to each control, not just the detail section itself.

This probably would have to happen in VBA in the OnFormat event
procedure. *Does anyone have a suggestion?

TIA,

Bruce

Close but no cigar.

I found that the size of each CanGrow control in the current Detail
section is available in the OnPrint event. * In the OnFormat event
it's possible to change the height of each control. * *Since OnPrint
executes before OnFormat, I had to run the report twice. *In the first
run, OnPrint writes the maximum control height for each line to a
table. *On the second run OnFormat retrieves that value and applies it
to the Height property of every control on the print line. *(I used a
key value from each line as a unique identifier, but a line number
would have worked as well).

This succeeds beautifully in making each control as high as the
tallest on the line. *Each line looks great. *The problem is that
spacing between lines is irregular.

CanGrow is set to True for the Detail section and its controls. * The
environment is Access 2007 SP2, using an Access 2003 format
database.

If anyone has any advice it would be very appreciated.

Correction - OnFormat executes before OnPrint.

Guessing
OK before we start, set all the control's Tags to 0
Scan all the controls in the report where the Tag is 0 and find the Lowest
value of the .Top position of each one and the height, so giving the bottom
of the control. Let's call this CtlA
Then find all the controls where the .Top is between the .Top and bottom of
CtlA and set the .Top = .Top(CltA), and set the Tag to +No of loops youhave
gone through. So on the next scan through, the .Top will be set to the
(.)Bottom of the previous row + a suitable gap. Finish the loop when there
are no more tags = 0 Phil
Thanks, Phil. .Top apparently refers to the distance of the control
from the top of the current detail section. The problem is the gaps
between detail sections on the report. Good idea, though.

Reply With Quote
  #9  
Old   
Phil
 
Posts: n/a

Default Re: Adjusting height of report controls at runtime via VBA - 09-01-2011 , 10:07 AM



Quote:
Guessing
OK before we start, set all the control's Tags to 0
Scan all the controls in the report where the Tag is 0 and find the Lowes
t
value of the .Top position of each one and the height, so giving the bott
om
of the control. Let's call this CtlA
Then find all the controls where the .Top is between the .Top and bottom
of
CtlA and set the .Top = .Top(CltA), and set the Tag to +No of loops you
have
gone through. So on the next scan through, the .Top will be set to the
(.)Bottom of the previous row + a suitable gap. Finish the loop when ther
e
are no more tags = 0 Phil

Thanks, Phil. .Top apparently refers to the distance of the control
from the top of the current detail section. The problem is the gaps
between detail sections on the report. Good idea, though.

Hi Bruce

AFIK, there is only 1 Section(AcDetail) on a report.

Yes, I found it took long time to grasp that measurements are from the top of
a section (and from the left)

I assumed the problem is with the gaps between the "rows" of controls on the
Detail section.

Phil

Reply With Quote
  #10  
Old   
brucedodds
 
Posts: n/a

Default Re: Adjusting height of report controls at runtime via VBA - 09-01-2011 , 10:41 AM



On Sep 1, 11:07*am, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:
Quote:
Guessing
OK before we start, set all the control's Tags to 0
Scan all the controls in the report where the Tag is 0 and find the Lowes
t
value of the .Top position of each one and the height, so giving the bott
om
of the control. Let's call this CtlA
Then find all the controls where the .Top is between the .Top and bottom
of
CtlA and set the .Top = .Top(CltA), and set the Tag to +No of loops you
have
gone through. So on the next scan through, the .Top will be set to the
(.)Bottom of the previous row + a suitable gap. Finish the loop when ther
e
are no more tags = 0 Phil

Thanks, Phil. * .Top apparently refers to the distance of the control
from the top of the current detail section. *The problem is the gaps
between detail sections on the report. * Good idea, though.

Hi Bruce

AFIK, there is only 1 Section(AcDetail) on a report.

Yes, I found it took long time to grasp that measurements are from the top of
a section (and from the left)

I assumed the problem is with the gaps between the "rows" of controls on the
Detail section.

Phil- Hide quoted text -

- Show quoted text -
Hi Phil,

Thanks. There's just one row in the Detail section. The gaps are
between one occurance of the detail section and the next on the
printout.

Bruce

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.