我有一份报告显示另一种表格的记录来源。当我在此表单上添加一些记录并单击报告时,不会显示此记录。如何才能实现屏幕显示 - 总之?这是我简单的报告代码:
Private Sub cmdOpenReport_Click()
DoCmd.OpenReport "MyReport", acViewReport
End Sub
Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = Forms![MyForm].Form.RecordSource
End Sub
答案 0 :(得分:0)
您需要在重新打开报告之前关闭报告并保存新记录。
在“打开报告”按钮的点击事件中,插入以下内容:
Private Sub OpenReport_Click()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acReport, "Test1", acSaveYes
DoCmd.OpenReport "Test1", acViewPreview
End Sub
答案 1 :(得分:0)
在打开报告之前尝试重新检查您的Forms Recordset:
Private Sub cmdOpenReport_Click()
Me.FilterOn = False
Me.Requery
DoCmd.OpenReport "MyReport", acViewReport
End Sub
答案 2 :(得分:0)
我有一个答案,我知道这不是那么容易(在OpenReport按钮的点击事件中):
Dim strWhere As String
Me.Dirty = False
With Me.Recordset.Clone
Do Until .EOF
strWhere = strWhere & "," & !ID
.MoveNext
Loop
End With
strWhere = Mid(strWhere, 2)
DoCmd.OpenReport "MyReport", acViewReport, WhereCondition:="ID In (" & strWhere & ")
Leigh Purvis(访问MVP)提供的答案,再次感谢BIG!