如何在MS Access中自动重新加载报表?

时间:2021-02-21 15:38:05

I have a report in MS Access where the underlying data in the tables changes irregularly. I'd like the report to reflect these changes automatically, either by reloading the form say every 10 seconds or either the report gets a notification about the changes and shows the new data. Is this possible?

我在MS Access中有一个报告,其中表中的基础数据不规则地更改。我希望报告能够自动反映这些更改,方法是每10秒钟重新加载一次表单,或者报告获取有关更改的通知并显示新数据。这可能吗?

1 个解决方案

#1


3  

The only way I can think of doing this is not elegant:

我能想到的唯一方法就是不优雅:

Create a hidden form with it's timer interval set to 10 seconds (or whatever interval you need). When the Forms' timer event fires, iterate through the open reports collection and close and re-open each one found.

创建一个隐藏的表单,其计时器间隔设置为10秒(或您需要的任何间隔)。触发Forms的计时器事件时,遍历打开的报告集合并关闭并重新打开找到的每个事件。

Something along the lines of:

有点像:

Public Sub RefreshOpenReports()
    Dim rpt As Report

    With Reports
        ' Iterate over all open reports...
        For Each rpt In Reports
            rpt.Requery
        Next
    End With

End Sub

#1


3  

The only way I can think of doing this is not elegant:

我能想到的唯一方法就是不优雅:

Create a hidden form with it's timer interval set to 10 seconds (or whatever interval you need). When the Forms' timer event fires, iterate through the open reports collection and close and re-open each one found.

创建一个隐藏的表单,其计时器间隔设置为10秒(或您需要的任何间隔)。触发Forms的计时器事件时,遍历打开的报告集合并关闭并重新打开找到的每个事件。

Something along the lines of:

有点像:

Public Sub RefreshOpenReports()
    Dim rpt As Report

    With Reports
        ' Iterate over all open reports...
        For Each rpt In Reports
            rpt.Requery
        Next
    End With

End Sub