我正在使用Access来创建动态报告,我希望在关闭事件中删除报告。 现在,我正在创建这样的报告:
Set rpt = CreateReport
With rpt
.Visible = True
.Caption = "Calendar View"
.BorderStyle = 1
.AutoCenter = True
.ScrollBars = 0
.Printer.Orientation = acPRORLandscape
.Modal = True
.PopUp = True
.OnClose = "[Event Procedure]"
End With
'extra stuff for report
strName = rpt.Name
DoCmd.Close acReport, strName, acSaveYes
DoCmd.Rename "rptNewName", acReport, strName
DoCmd.OpenReport "rptNewName", acViewPreview, , , acWindowNormal
DoCmd.DeleteObject acReport, "rptNewName"
但是,DeleteObject会抛出错误,因为报告仍然打开.. 如何删除关闭事件的报告?
谢谢!
答案 0 :(得分:1)
在排队DoCmd.DeleteObject ...
之前放置以下内容Do While Application.CurrentProject.AllReports(sRptName).IsLoaded
DoEvents
Loop