Murray Brown
asked on
Access VBA - automatically fit size of label to text
Hi
I ahve a report where labels are automatically populated with data and centred. My only problem is
that sometimes the text is too long for the label so a portion of it gets hidden. What VBA code would I use to automatically size the label to fit whatever text is in it.
Thanks
I ahve a report where labels are automatically populated with data and centred. My only problem is
that sometimes the text is too long for the label so a portion of it gets hidden. What VBA code would I use to automatically size the label to fit whatever text is in it.
Thanks
have you tried setting the property Can Grow and Can Shrink to Yes?
you may also try this
http://www.lebans.com/textwidth-height.htm
http://www.lebans.com/textwidth-height.htm
ASKER
Hi
I can't ssem to find that property in my label. Pity they aren't in alphebetical order
I can't ssem to find that property in my label. Pity they aren't in alphebetical order
ASKER
looked at that link and can't see what you mean
download the file TextHeightWidth.zip from the link and see if you can apply the method used in the sampledb
ASKER
That example is pretty complex. Surely Microsoft have a simpler way to do something so obviously necessary!
here is what you can do..
check the length of the caption (how many characters will fit in the Label using the default font size)
then do this
assuming the max number of characters that will fit using the default font that you have is 25
select case Len(me.labelx.caption)
case 26-28
me.labelx.fontsize=10
end select
something like that
can you upload your db...
end select
check the length of the caption (how many characters will fit in the Label using the default font size)
then do this
assuming the max number of characters that will fit using the default font that you have is 25
select case Len(me.labelx.caption)
case 26-28
me.labelx.fontsize=10
end select
something like that
can you upload your db...
end select
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much
ASKER
To anyone who reads this post: I found a far more workable solution to my initial question. I stretched the label manually to the width of the report and then set the TextAlign property to "Centre"