动态调整报表详细信息区域的大小
是否可以在 MS Access 中动态调整报告的详细信息区域的大小?
我有一个报告,详细信息区域有 2 行,我希望其中一行是“可选”的 - 当没有数据时,它不应显示,并且详细信息区域应该只与最上面一行数据一样高。
我有这样的代码:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim reduceHeight As Integer
reduceHeight = Me.Label83.Height
If IsNull(Me.data_1) Then
Me.data_1.Visible = False
Me.Label83.Visible = False
Else
Me.data_1.Visible = True
Me.Label83.Visible = True
End If
If IsNull(Me.data_1)
Detail.Height = Detail.Height - reduceHeight
End If
End Sub
它可以使标签和文本框有条件地可见,但当隐藏底线时我无法让详细信息区域缩小。我确实将详细信息的CanShrink
属性设置为True
,但它没有缩小。
Is it possible to resize the Detail area of a report dynamically, in MS Access?
I have a report and the Detail region has 2 rows, I'd like one of them to be "optional" - when there is no data it should not display and the Detail region should only be as tall as the top row of data.
I have code like this:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim reduceHeight As Integer
reduceHeight = Me.Label83.Height
If IsNull(Me.data_1) Then
Me.data_1.Visible = False
Me.Label83.Visible = False
Else
Me.data_1.Visible = True
Me.Label83.Visible = True
End If
If IsNull(Me.data_1)
Detail.Height = Detail.Height - reduceHeight
End If
End Sub
And it works as far as makign the label and text box conditionally visible, but I can't get the Detail region to shrink when the bottom line is hidden. I did set the CanShrink
property for the Detail to True
, but it doesn't shrink.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也为您的控件(例如文本框)设置CanShrink:
Set CanShrink for your controls too (e.g. textboxes):
嗨:我知道你有标签。由于标签无法缩小,因此您需要编写一些代码。
动态地处理报表是一项棘手的任务。当您更改部分的高度或宽度时,所有控件都必须保留在新区域内,否则会出现问题。
当您移动控件时,它必须保持在该部分的区域内,否则您会遇到问题。另外,您应该禁用该部分的自动收缩。
现在,这是一个例子。您应该修改它以满足您的要求。
报告的代码如下:
这种近似方法使您可以完全控制报告,即使报告上有标签、图像或其他内容,它也能正常工作。
Hi: I understand that you have labels. Since labels cannot shrink, you'll need to write some code.
Dynamically playing with reports is a tricky task. When you change a section's height or width all the controls must keep inside the new area, otherwise you'll have problems.
When you move a control, it must keep inside the section's area, otherwise you'll have problems. Also, you should disable Autoshrink for the section.
Now, this is an example. You should modify it to meet your requirements.
Here goes the code for the report:
This approximation gives you complete control over your report and works even if you have labels, images or whatever on it.