View Full Version : CanShrink doesn't shrink labels!


wiklendt
05-04-2008, 08:11 PM
what can i do?? i have a label and its control. when the control has no data, fine, the CanShrink property makes it disappear from my report, however, its label remains behind, making the report look 'unfinished' or not filled in properly. if the labels and associated white space from the label/control was shrunk also, then nothing would look out of place.

is there a way i can make the label disappear (along with the white space) if there is no data for that control? i've tried setting the seciton to shrink, but that doesn't work either. i think it treats a label as input on a report, so it doesn't shrink the section if there are labels in it.

i've tried placing and if statement with somethin to the effect of:

IF IsNull(me!control) Then label.visible = False End If

but access didn't like it, i guess that's the wrong approach. i'm afraid i can't remember the error message, but i could replicate it if people want me to.

thanks in advance.

agnieszka.



there is no 'CanShrink' available to set for the labels

and the only other post that touches on this was remained unresolved in 2002!

shadow9449
05-04-2008, 10:13 PM
Why don't you use a text box instead of a label? You can set the control source to ="XYZ" (or whatever your label reads). You can do conditional formatting as well, so if the data in the text box is null, the text box acting as your label can be null as well and then shrink.

SHADOW

wiklendt
05-04-2008, 10:38 PM
hey thanks shadow... how weird is that? i just read a similar tip thru google!! hopefully, this will eliminate white space too - i'll try it tonight.

hmmm... if only i could think of a way to code "all nulls, shrink 'text'-label and control" rather than "if control 1 is null, shrink text 1; if control 2 is null.... etc... control 15... etc..."

shadow9449
05-05-2008, 09:29 PM
hey thanks shadow... how weird is that? i just read a similar tip thru google!! hopefully, this will eliminate white space too - i'll try it tonight.

hmmm... if only i could think of a way to code "all nulls, shrink 'text'-label and control" rather than "if control 1 is null, shrink text 1; if control 2 is null.... etc... control 15... etc..."

The reason you can't is because there is no relationship between the text's "label" textbox and the textbox itself. I usually use an Iif condition in the control source. E.g. =iif (Isull (textbox), Null, "Label title")

SHADOW

wiklendt
05-05-2008, 10:06 PM
hey,

this is what i ended up doing, and it's working for me (so far!)

How to get labels in an Access report to ‘shrink’ when its control is null

* Set control to shrink.
* Convert label to textbox, enter the label name as control source ( =”Label name” ) without the parentheses
* Now you can set the ‘label’ textbox to CanShrink and also, set the Visible property to No.
* Now, in VB in the “On Format” part for the section containing the controls enter this code for each control/label pair...

Me.lblTextbox.Visible = Not IsNull(Me.txtTextbox)

And Bob’s your auntie.

although i have to place this code in for each control/label pair, i don't have too many and it's not too painful b/c i name my control and label identically, except the labels have prefix 'lbl' and controls have prefix 'txt' (in this example)