How to automatically reload a report in MS Access?

2019-07-13 02:51发布

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?

1条回答
Lonely孤独者°
2楼-- · 2019-07-13 03:14

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.

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
查看更多
登录 后发表回答