vba 具有动态改变文本框大小的访问报告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26099041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Access Report with dynamically changing text box size
提问by Kaja
Is it possible to have a report with flexible text width and height? I sometimes have two words in this text and some times hundreds. I want to have small text for the first and big text for the second. How do I do that?
是否可以拥有具有灵活文本宽度和高度的报告?我有时在这篇文章中有两个词,有时有数百个。我想要第一个文本和第二个大文本的小文本。我怎么做?
回答by E Mett
Use the Detail_Format
event.
使用Detail_Format
事件。
It fires before each line, and you can change the formatting based on the length of the text.
它在每一行之前触发,您可以根据文本的长度更改格式。
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Len(Field1) < 10 Then
txtField1.FontSize = 18
Else
txtField1.FontSize = 12
End If
End Sub
回答by hkhan
I would advise you to set a your text box size to what you think is optimum and use the CanShrink
and CanGrow
properties (tap the text box and then open the properties windows and you can find them there).
我建议您将文本框大小设置为您认为最佳的大小并使用CanShrink
和CanGrow
属性(点击文本框,然后打开属性窗口,您可以在那里找到它们)。
The CanGrow
property indicates whether the size of the text box can increase vertically according to its content. Similarly, CanShrink
decreases the height of the text box according to its content. Hereis a link for better understanding these two properties.
该CanGrow
属性指示文本框的大小是否可以根据其内容垂直增加。同样,CanShrink
根据文本框的内容减小文本框的高度。这是一个更好地理解这两个属性的链接。