Is it possible to use the conditional formatting to see that the text won't "overspill" a line?
so it shrinks the font size?
OR
make an condition that if current data is longer than 20chars then set fontsize 10, longer than 30, size 8 and so on?
Is it possible to use the conditional formatting to see that the text won't "overspill" a line?
so it shrinks the font size?
OR
make an condition that if current data is longer than 20chars then set fontsize 10, longer than 30, size 8 and so on?
Have you tried? That sounds like a very long formula. Build a function that can be called from CF rule.
I set text for a non-proportional font, limit number of characters in table design and set textbox size to fit longest possible text if I don't want to allow textbox to shrink/grow on report so report page does not change in length.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Tried?, actually, no, my knowledge don't stretch so far, it took me over 4 hours to get [Platform]="PlayStation 5" to work as an expression condition to change the color.
And then I already had that code from my trials with libreoffice.
I only started to use access yesterday, first time ever...
I was actually thinking about something smaller, since all we actually need is an expression, like: [Title]$char>30 and then let the built-in conditional formatting do the rest.
But I actually have no idea if there is a code that works like that?
Something like:
Len([textboxname])>=30
I just checked CF rule and there is no option for setting font size. Can't use CF for this. Could use VBA but be aware that using VBA to set properties of controls on form affects ALL instances of control, not just current record.
Last edited by June7; 11-07-2021 at 07:57 PM.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
dang! I actually just assumed it since it had colors and bold, underlined...
ok, plan B, is there something called conditional printing? (exist in libreoffice)? cause then I could have 2,3 "title" boxes upon each other, and just show the one with fontsize 12 if letters < 15, and one with fontsize 10 if letters are >15&&<20...
surely an conditional show/hide function must exist?
in a report there are the onformat and onprint events for each section - so you can put code in those events to change font size. But usually you would use the control can shrink/grow properties to allow for longer text which requires no code at allis there something called conditional printing?
Form controls also have these properties but they are only applied if you print the form
see this link where pretty much the same question was asked
https://www.access-programmers.co.uk.../#post-1787940
no, usual solution is to set the forecolor to the same as the backcolorsurely an conditional show/hide function must exist?
Well, unfortunately doesn't transparent color exist as font color..
But how about what I wrote in no. 5 here, use 2 similar text boxes, and use something like:
if Len([Title])>=30 then [textbox1].visible=no && [textbox2].visible=yes
..but of course use a valid code (I can't code)
set the back color to the same as the section color and don't use transparent. Or set the forecolor to the section color rather than the control backcolor
With regards your code, learn how access works - it does not work the same as libre
if Len([Title])>=30 then [textbox1].visible=no && [textbox2].visible=yes
so you might use
Code:[textbox1].visible=Len([Title])<30 [textbox2].visible=Len([Title])>=30
or
you decide which way you want to goCode:If Len([Title])>=30 then [textbox1].visible=false [textbox2].visible=true else [textbox1].visible=true [textbox2].visible=false end if
Or you could just make the one textbox wider and hide borders, and/or set justify to centre or right
or if you want to change font size then code something like
or use the cangrow property as already suggested - this only affects the height of the control, not the widthCode:Select Case Len(Title) case<30: txtBox.fontsize=11 case <40 txtbox.fontsize=10 case <50 txtbox.fontsize=9 case else txtbox.size=8 End Select
to find out more google/bing something like 'access vba cangrow' or 'access vba some term or other'. You will find the MS documentation, posts on this and other forums that may or may not be relevant depending on how focussed your search phrase is
wow, thx for the information, now I got a starting point!
Whilst doing this is certainly possible, I would strongly advise against it.
The code is unnecessarily complex and, in my opinion anyway, the end result can look a compete mess.
Instead I suggest using a zoom form to display text which is too long to fit in the available space. For example:
If you want to see how that was done, please read my article Move Forms & Controls - Mendip Data Systems