Open a form using ID from a different form in Access 2010 using vba

流过昼夜 提交于 2019-12-05 21:46:19
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

I have the answer..thanks all for your help..what i ended up doing was get ID from Contracts_all form and each time I reopen the contracts form.here's my code

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!