Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to open a form from a button in another form. The form with the button,contracts_all form, has a field ID and I want to open up the form that contains the information with that ID. This second form,contracts, has additional information and has buttons that allow editing of that particular contract. I have managed to get something but it's giving me a 'Run -time error 2489. Form contracts not open' The code is below. Thanks in advance.

Private Sub Command74_Click()
    ID = [Forms]!Contracts_all![ID]
    DoCmd.GoToRecord acDataForm, "Contracts", ID
End Sub
like image 588
KuroNeko Avatar asked Nov 18 '25 21:11

KuroNeko


1 Answers

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
like image 121
Johnny Bones Avatar answered Nov 21 '25 14:11

Johnny Bones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!