3

我正在尝试从另一个表单的按钮打开一个表单。带有按钮contracts_all 表单的表单有一个字段ID,我想打开包含该ID 信息的表单。第二种形式,合同,具有附加信息,并具有允许编辑该特定合同的按钮。我设法得到了一些东西,但它给了我一个“运行时错误 2489。表单合同未打开”代码如下。提前致谢。

Private Sub Command74_Click()
    ID = [Forms]!Contracts_all![ID]
    DoCmd.GoToRecord acDataForm, "Contracts", ID
End Sub
4

2 回答 2

1
Dim Rs As Recordset
Dim Test As Integer
Dim varBookmark As Variant

DoCmd.OpenForm "Contracts"


Set Rs = Forms!Contracts.RecordsetClone

    Rs.FindFirst ("[ID] = '" & Me![ID] & "'")

varBookmark = Rs.Bookmark
Forms!Contracts.Form.Bookmark = varBookmark

If Rs.NoMatch Then
  MsgBox "That does not exist in this database."
Else
End If
于 2013-06-11T15:54:02.283 回答
1

我有答案..谢谢大家的帮助..我最终做的是从 Contracts_all 表格中获取 ID,每次我重新打开合同表格时。这是我的代码

Private Sub next_Click()
    On Error GoTo Err_next_Click
    DoCmd.SelectObject acForm, "contracts_all"
    DoCmd.GoToControl "ID"

    DoCmd.GoToRecord , , acNext
    DoCmd.OpenForm "Contracts", , , "ID = " & Forms!contracts_all![ID]

Exit_next_Click:
    Exit Sub

 Err_next_Click:
    MsgBox Err.Description
    Resume Exit_next_Click

 End Sub
于 2013-06-12T16:28:21.337 回答