How to squeeze out vertical space when controls have no value?

C

ccw

MSAccess 2003
My simple form has several fields arranged vertically in the detail section.
Some of the fields may have null or zero-length string values.
I have the Can Shrink property of each control set to "Yes".
In the code for the Detail_Format event, I have the following type of logic,
replicated for each control:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Me.Controls("Description").Visible = True

If Me.Controls("Background").Text = "" Then
Me.Controls("Background").Visible = False
End If

'Same thing for next control....
'Same thing for next control....

End Sub

In the debugger I can see that the Visible property is set to Flase when the
text value of the control is "".

WHAT I DO NOT GET IS why the print preview still shows vertical space where
there is a shrinkable invisible control.

Thanks in advance. -CCW
 
A

Albert D. Kallal

I would suggest that you create a report.

You simply set a text box 'can shrink" property to yes, and if it has no
value, then data is moved up.

YOU DO NOT need code to solve this problem.

I never tried this when printing a form, but I NEVER try to print forms, I
create a report with the information and use that.

So, as a suggestion do try and built a report.

So, try the setting the can shrink property to yes. Also, make sure contorls
don't overlap, else this will not work.
 
C

ccw

Albert, Thanks for the speedy reply.
It is in fact a Report and not a Form - my mistake.

Textboxes are still set to be visible, shrinkable, growable. Code was
removed.
Textboxes do not overlap.

On Print Preview, now (same test data) the textbox LABELS appear for those
rows that the code previously detected as <control>.Text = "" and nothing is
visible in the data part of the textbox for those rows.

Could this result from the actual data value being a non-printable like
linefeed or carriage return only?

Puzzled,
-CCW
 

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