I have a datasheet, and upon the user double clicking in one of the fields of a record, the code is meant to open a form (based on the same underlying table), and open at the record that the user clicked in.
** START CODE
Dim db As Database
Set db = CurrentDb
Dim rst As Recordset
Set rst = db.OpenRecordset("Customers", dbOpenDynaset)
rst.FindFirst "[ID] = " & Me.ID
If rst.NoMatch = False Then
DoCmd.OpenForm "Form View"
Forms![Commercial Record View].Bookmark = rst.Bookmark
rst.Close
Exit Sub
End If
rst.Close
Exit Sub
*** END CODE
When the above code runs, I keep getting a "Not a valid bookmark" error, except if I click in the very first record in the datasheet. In that case, it opens the form up with no errors returned.
Could someone please shed some light on this for me..
Thanks very much
Peter
** START CODE
Dim db As Database
Set db = CurrentDb
Dim rst As Recordset
Set rst = db.OpenRecordset("Customers", dbOpenDynaset)
rst.FindFirst "[ID] = " & Me.ID
If rst.NoMatch = False Then
DoCmd.OpenForm "Form View"
Forms![Commercial Record View].Bookmark = rst.Bookmark
rst.Close
Exit Sub
End If
rst.Close
Exit Sub
*** END CODE
When the above code runs, I keep getting a "Not a valid bookmark" error, except if I click in the very first record in the datasheet. In that case, it opens the form up with no errors returned.
Could someone please shed some light on this for me..
Thanks very much
Peter