CanShrink doesn't shrink labels! (1 Viewer)

wiklendt

i recommend chocolate
Local time
Today, 16:29
Joined
Mar 10, 2008
Messages
1,746
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.

[edit]

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

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

[/edit]
 
Last edited:

shadow9449

Registered User.
Local time
Today, 02:29
Joined
Mar 5, 2004
Messages
1,037
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

i recommend chocolate
Local time
Today, 16:29
Joined
Mar 10, 2008
Messages
1,746
text box may just do it...!`

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

Registered User.
Local time
Today, 02:29
Joined
Mar 5, 2004
Messages
1,037
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

i recommend chocolate
Local time
Today, 16:29
Joined
Mar 10, 2008
Messages
1,746
solution to: CanShrink labels

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...
Code:
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)
 
Last edited:

Tallbloke

Registered User.
Local time
Today, 07:29
Joined
Aug 17, 2006
Messages
66
Sorry to reply to such an old thread but I really can't get this to work on my reports!

I have labels that I have converted to text boxes that I want to disappear if the control is empty and I can't get anythig to happen at all :(
 

Tallbloke

Registered User.
Local time
Today, 07:29
Joined
Aug 17, 2006
Messages
66
After spending hours on this, I decided the neatest work round would be to include the label in the control...

Code:
="Arrive Time: " & [ArriveTime4]

and then use this code in the OnLoad section of the report

Code:
If Me.ArriveTimeCombo4 = "Arrive Time: " Then
Me.ArriveTimeCombo4.Visible = False
Else: Me.ArriveTimeCombo4.Visible = True
End If

Remembering to make sure the name of the control is different from the source.
 

Users who are viewing this thread

Top Bottom