访问VBA打开新窗体上的所有记录,但显示指定的记录

访问VBA打开新窗体上的所有记录,但显示指定的记录,vba,ms-access,records,openform,Vba,Ms Access,Records,Openform,我有一个带有ID号的表单,以及用来打开另一个带有相关记录的表单的按钮。除了要显示的特定记录之外,我还需要打开所有记录,因为我的表单需要有“下一步”和“上一步”按钮。我已经尝试了几天了,但我无法同时打开所有的记录和显示一个特定的记录。在这里,我重新开始使用向导打开所有记录。我应该如何修复它,使其显示单击的记录 Private Sub Command74_Click() On Error GoTo Err_Go_to_Click Dim stDocName As String Dim stLin

我有一个带有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

提前谢谢

打开表单后,您需要导航到正确的记录。 我看不到填充strLinkCriteria的代码,所以我在示例中提供了一些虚拟数据

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