我有一个带有 ID 号的表单,以及用于打开另一个包含相关记录的表单的按钮。除了显示的特定记录外,我还需要打开所有记录,因为我的表单需要具有有效的下一个和上一个按钮。我已经尝试了几天了,但我无法同时打开所有记录并展示特定的作品。所以在这里我重新开始使用向导打开所有记录。我应该如何修复它才能显示点击的记录?
Private Sub Command74_Click()
On Error GoTo Err_Go_to_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Contracts"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Go_to_Click:
Exit Sub
Err_Go_to_Click:
MsgBox Err.Description
Resume Exit_Go_to_Click
End Sub
提前致谢!
最佳答案
您需要在打开表单后导航到正确的记录。 我没有看到填充 stLinkCriteria 的代码,因此我在示例中提供了一些虚拟数据。
Private Sub Command74_Click()
On Error GoTo Err_Go_to_Click
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = "ContactID = '" & Me.ContactID & "'"
stDocName = "Contracts"
'Open the form with no filter
DoCmd.OpenForm stDocName
'Go to the specified record
Forms(stDocName).Recordset.FindFirst stLinkCriteria
Exit_Go_to_Click:
Exit Sub
Err_Go_to_Click:
MsgBox Err.Description
Resume Exit_Go_to_Click
End Sub
关于vba - Access VBA 在新窗体上打开所有记录,但显示指定记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17067923/