vba 访问报告:每个详细信息的第二页上的页眉
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5869766/
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: Page header on second page on per detail
提问by Rick
I want to display a header only on the second page and beyond but PER record. The first page of the new detail should not have the page header visible.
我只想在第二页及以后显示标题,但要显示 PER 记录。新详细信息的第一页不应显示页眉。
Originally I had the following code
最初我有以下代码
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
Me.PageHeaderSection.Visible = Not (Me.Page = 1)
End Sub
It displays the header on everyother page except the first.
它在除第一页之外的所有其他页面上显示标题。
I want the header to be visible after the first page (but not including the first page) for each group.
我希望标题在每个组的第一页(但不包括第一页)之后可见。
采纳答案by Rick
I created this simple sub that seems to do the trick. Basically, for each page, it checks if the group is the same as before. If it is different it assumes that it is the first page of the group and doesn't display the header.
我创建了这个简单的 sub 似乎可以解决问题。基本上,对于每个页面,它检查组是否与以前相同。如果不同,则假定它是组的第一页并且不显示标题。
'At the top of the module window I created a "Module-Level Variables".
Dim current_group As Integer
Dim temp_group As Integer
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
current_group = Int(Me.MyGroupID)
If current_group = temp_inst Then
Me.PageHeaderSection.Visible = True
Else
Me.PageHeaderSection.Visible = False
End If
temp_group = current_group
End Sub
回答by Frank Scheidell
Way too complicated.
方式太复杂了。
The first one was better!
第一个更好!
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
Me.PageHeaderSection.Visible = Not (Me.Page = 1)
Debug.Print "Page " & Me.Page & " Visible = " & Not (Me.Page = 1)
End Sub
回答by TheOtherTimDuncan
In the Sorting and Grouping for the report, add the field that identifies the record and that you want to group on. In the OnFormat event of that section header, do the same thing you're doing above: RecordHeader.Visible=(Me.Page<>1)
在报告的排序和分组中,添加标识记录和要分组的字段。在该部分标题的 OnFormat 事件中,执行与上面相同的操作: RecordHeader.Visible=(Me.Page<>1)