How to shrink report detail section

S

Sirocco

OK fellow brainiacs, I'm trying to control the height of the detail section
of a report with an On Format procedure that includes the following:

Me.Detail.Height = ?

I want to change the height of the detail section from about 1.3 inches to 1
inch. What number and units do I use?

Bonus points: the detail section has 5 labels listed in a column. If the
corresponding data value is null, I make the label invisible, but is there a
way to have the detail section shrink in height a corresponding amount?

Thanks in advance!
 
M

Marshall Barton

Sirocco said:
OK fellow brainiacs, I'm trying to control the height of the detail section
of a report with an On Format procedure that includes the following:

Me.Detail.Height = ?

I want to change the height of the detail section from about 1.3 inches to 1
inch. What number and units do I use?

Bonus points: the detail section has 5 labels listed in a column. If the
corresponding data value is null, I make the label invisible, but is there a
way to have the detail section shrink in height a corresponding amount?



You can not reduce the Height of a section to less than the
height required to display all the controls in the section.

The units are in twips, 1440 per inch.

To make the height of the section automatically shrink when
a value is Null (or a zero length string) use the CanShrink
property for both the control and its section. Make the
label associated with the text box invisible so it doesn't
prevent shrinking the section. If the label is "attached"
to a text box, you can just make the text box invisible and
its label will become invisible too:

Me.thetextbox.Visible = Not IsNull(Me.thetextbox)
 
S

Sirocco

Thanks, this works. Also, is there a way to get vertical lines in the
detail section, which separate columns, to also shrink or grow to fit the
detail section height? It seems they will do this if the lines are the same
ht as the section and each detail is "simple", but not if the detail section
includes a column of fields that use the previously discussed
visible/invisible code. Or is there a way to do this?

Many thanks in advance.
 
M

Marshall Barton

Sirocco said:
Thanks, this works. Also, is there a way to get vertical lines in the
detail section, which separate columns, to also shrink or grow to fit the
detail section height? It seems they will do this if the lines are the same
ht as the section and each detail is "simple", but not if the detail section
includes a column of fields that use the previously discussed
visible/invisible code. Or is there a way to do this?

I usually do the verticle lines using the Line method in the
detail's Print event. By then the detail's Height has been
adjusted to the Grow/Shrink height so you can determine how
long to make it. If you want the line to go to the bottom
of the section, then just make the line very long and it
will be cropped at the bottom of the section:

Me.Line (Me.sometestbox.Left, 0) - Step(0, 10000)

The units of the coordinates default to twips (1440 per
inch).
--
Marsh
MVP [MS Access]


 
S

Sirocco

Whoops, you lost me. What is "sometestbox"? Also, do you mind giving me
the entire formula to calculate the line height?

Thanks


Marshall Barton said:
Sirocco said:
Thanks, this works. Also, is there a way to get vertical lines in the
detail section, which separate columns, to also shrink or grow to fit the
detail section height? It seems they will do this if the lines are the same
ht as the section and each detail is "simple", but not if the detail section
includes a column of fields that use the previously discussed
visible/invisible code. Or is there a way to do this?

I usually do the verticle lines using the Line method in the
detail's Print event. By then the detail's Height has been
adjusted to the Grow/Shrink height so you can determine how
long to make it. If you want the line to go to the bottom
of the section, then just make the line very long and it
will be cropped at the bottom of the section:

Me.Line (Me.sometestbox.Left, 0) - Step(0, 10000)

The units of the coordinates default to twips (1440 per
inch).
--
Marsh
MVP [MS Access]


inches
to 1
 
M

Marshall Barton

Sirocco said:
Whoops, you lost me. What is "sometestbox"?

I just made the assumption that you wanted the line's
horizontal position to be relative to some text box in the
report. You can change "sometestbox" to whatever is
appropriate for your needs.

Also, do you mind giving me
the entire formula to calculate the line height?

As I said before, you probably don't need to calculate the
line's height, but if you want the line to be short of the
bottom of the section, then tell me how the line is related
to either the section or some controls.
 
S

Sirocco

I want the line ht to be equal to the detail section ht, so I tried
me.line.height = me.detail.height, in the print event (got error) and then
tried the on format event (didn't work). Are you familiar with this
situation?

Many thanks!


Marshall Barton said:
Sirocco said:
Whoops, you lost me. What is "sometestbox"?

I just made the assumption that you wanted the line's
horizontal position to be relative to some text box in the
report. You can change "sometestbox" to whatever is
appropriate for your needs.

Also, do you mind giving me
the entire formula to calculate the line height?

As I said before, you probably don't need to calculate the
line's height, but if you want the line to be short of the
bottom of the section, then tell me how the line is related
to either the section or some controls.
--
Marsh
MVP [MS Access]


 
M

Marshall Barton

Sirocco said:
I want the line ht to be equal to the detail section ht, so I tried
me.line.height = me.detail.height, in the print event (got error) and then
tried the on format event (didn't work). Are you familiar with this
situation?

Sure, that's what I suggested originally:

Me.Line (????, 0) - Step(0, 10000)

must be in the Print event and will draw a vertical line
from the top (first zero) of the detail to however tall (up
to 10000 twips or 14.4 inches) the detail section ends up
being.

You still need to explain where you want the line positioned
horizontally within the detail section/
--
Marsh
MVP [MS Access]


 
S

Sirocco

I'm sorry, but I don't recognize what you're giving me as what I'm using.
I'm not familiar with the "Line" method, and what is "Step"? Please give
me the full equation. (I did this a few years ago but forgot how I did it).

This is what I have:
Me.Linename.Height = Me.Linename(69000, 0) - Step(0, 10000)
where 69000 is the x distance in twips. When I run this, "Step" is
highlighted in yellow. Maybe I don't have the right reference library
loaded. Also, where does the height of the detail section come into play?

Thanks again.


Marshall Barton said:
Sirocco said:
I want the line ht to be equal to the detail section ht, so I tried
me.line.height = me.detail.height, in the print event (got error) and then
tried the on format event (didn't work). Are you familiar with this
situation?

Sure, that's what I suggested originally:

Me.Line (????, 0) - Step(0, 10000)

must be in the Print event and will draw a vertical line
from the top (first zero) of the detail to however tall (up
to 10000 twips or 14.4 inches) the detail section ends up
being.

You still need to explain where you want the line positioned
horizontally within the detail section/
--
Marsh
MVP [MS Access]


fit
the column.
If but
is
 
M

Marshall Barton

Sirocco said:
I'm sorry, but I don't recognize what you're giving me as what I'm using.
I'm not familiar with the "Line" method, and what is "Step"? Please give
me the full equation. (I did this a few years ago but forgot how I did it).

This is what I have:
Me.Linename.Height = Me.Linename(69000, 0) - Step(0, 10000)
where 69000 is the x distance in twips. When I run this, "Step" is
highlighted in yellow. Maybe I don't have the right reference library
loaded. Also, where does the height of the detail section come into play?

You have several misperceptions here. First the method is
LINE, not Linename. Second, there is no Height property to
mess with. Finally, you should not be using an assignment
statement, the entire **Statement** is:

Me.Line (69000, 0) - Step(0, 10000)

which draws the line directly on the page. Another problem
is that 69000 twips would be almost fifty inches from the
left margin, way beyond the width of the paper. Maybe you
meant 6900 instead??

As far as the meaning of Step, it is used to indicate that
the second set of coordinates are relative to the first set.
The 0 in Step(0, ...) means that the line ends at the same X
coordinate as its starting point, i.e. it's a vertical line.
It could be written without Step:
Me.Line (6900, 0) - (6900, 10000)

Ordinarily, I'd respond to this kind of question by telling
you to look it up in Help. Unfortunately, the later
versions af Access Help is at best difficult to use, and in
the case of the Line method, just plain wrong (it looks as
if they copied/pasted the description from a C man-page?).

Because Help is so messed up, I'll post the help topic from
A97
-------------------------------------------------------------------
The Line method draws lines and rectangles on a Report
object when the Print event occurs.

Syntax
object.Line [[Step](x1,y1)] – [Step](x2,y2)[,[color][,B[F]]]

You can use this method only in an event procedure or a
macro specified by the OnPrint or OnFormat event property
for a report section, or the OnPage event property for a
report.
The Line method has the following arguments.

Argument Description
object The Report object on which the line or rectangle is
to be drawn.
Step A keyword that indicates the starting point
coordinates are relative to the current graphics position
given by the settings for the CurrentX and CurrentY
properties of the object argument.
x1, y1 Single values indicating the coordinates of the
starting point for the line or rectangle. The Scale
properties (ScaleMode, ScaleLeft, ScaleTop, ScaleHeight, and
ScaleWidth) of the Report object specified by the object
argument determine the unit of measure used. If this
argument is omitted, the line begins at the position
indicated by the CurrentX and CurrentY properties.
Step A keyword that indicates the end-point coordinates are
relative to the line's starting point.
x2, y2 Single values indicating the coordinates of the end
point for the line to draw. These arguments are required.
color A Long value indicating the RGB (red-green-blue) color
used to draw the line. If this argument is omitted, the
value of the ForeColor property is used. You can also use
the RGB function or QBColor function to specify the color.
B An option that creates a rectangle by using the
coordinates as opposite corners of the rectangle.
F F cannot be used without B. If the B option is used, the
F option specifies that the rectangle is filled with the
same color used to draw the rectangle. If B is used without
F, the rectangle is filled with the color specified by the
current settings of the FillColor and BackStyle properties.
The default value for the BackStyle property is Normal for
rectangles and lines.
Remarks

To connect two drawing lines, make sure that one line begins
at the end point of the previous line.
The width of the line drawn depends on the DrawWidth
property setting. The way a line or rectangle is drawn on
the background depends on the settings of the DrawMode and
DrawStyle properties.
When you apply the Line method, the CurrentX and CurrentY
properties are set to the end point specified by the x2 and
y2 arguments.



 
S

Sirocco

Thanks for the details. I also checked the Microsoft online knowledge base,
which I should have done in the first place and which had exactly what I was
looking for. The "line" method is definitely convenient; you can't have a
truly professional looking report without vertical lines.

Thanks!
 
S

Stephen Lebans

For some sample code using thr Report objects Line method see the older
non class based solution here:
http://www.lebans.com/PrintLines.htm
PrintLinesA97 - Create Vertical lines, Borders and boxes with VBA code.

New Ver 19 January 20, 2002. Added support for vertically centering the
contents of a TextBox or Label control.

How to create a margin for your TextBox.
How to Draw Vertical lines the entire vertical length of your Report.
How to Draw a Grid.
How to force the contents of a Memo field to fit within a fixed sized
control.
Lots of other stuff!
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

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