强制报告页脚位于页面底部

时间:2011-12-19 20:08:05

标签: ms-access ms-access-2007 report

在Microsoft Access 2007中,

有没有办法在最后一页底部显示“报告页脚”部分?现在我的报告页脚部分始终遵循我的详细信息部分,因此它最终会在任何地方结束。

我希望尽可能避免使用VBA。

2 个答案:

答案 0 :(得分:3)

是否必须是报告页脚,或者您是否希望文本显示在报告最后一页的页面底部?如果是这样,那么可以用很少的VBA来完成:

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
If Page = Pages Then
   Me.[TextBoxName].Visible = True
Else
   Me.[TextBoxName].Visible = False
End If
End Sub

这个想法是你在页面页脚中放置一个文本框,只在最后一页上显示它。

此外,您可能希望阅读http://support.microsoft.com/kb/208979/en-us

答案 1 :(得分:2)

我发现了一种更好的方式here - 您可以拥有一个大型报表页脚,但不会占用页面上一半的空间用于详细信息部分

基本上您需要在报告中添加以下代码(尽管您可以将其放在一个通用模块中):

Sub SetGrpFtrLoc(Rpt As Report, GrpFtrLoc As Double)
    GrpFtrLoc = GrpFtrLoc * 1440        'Convert from inches to twips.
    If Rpt.Top < GrpFtrLoc Then         'Not at location yet, so
        Rpt.MoveLayout = True           'move to next print location.
        Rpt.NextRecord = False          'Do not go to next record.
        Rpt.PrintSection = False        'Do not print the section.
    End If                              'Until the required offset is reached
End Sub

然后,您可以将以下内容放入报告页脚的格式化的事件过程中。

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    Call SetGrpFtrLoc(Me.Report, 8)     'Display report footer at least
                                        '8 inches from the top of the page
End Sub

(MS的例子使SetGrpFtrLoc成为一个函数并直接在Report Footer的On Format事件中调用它,在我的情况下我需要在On Format事件中做其他事情,所以我把它变成了一个子)