Not played around with bookmarks much, but wanted to use it to get back to a record after a requery on the form.
My code for the Requery button is
Private Sub cmdRequery_Click()
Dim lngId As Long
Dim rst As DAO.Recordset
Dim strCriteria As String
Dim varBookMark As Variant
' Save record so requery on subform will pick up all last record written
If Me.Dirty Then Me.Dirty = False
lngId = Me.ID
varBookMark = Me.Bookmark
strCriteria = "ID=" & lngId
'Set rst = Me.sfrmEmails.Form.Recordset
' Requery the subform
' Go back to record we were on
' Now the sub form
'Set rst = Nothing
DoCmd.GoToRecord acDataForm, Me.Name, acPrevious, 5 ' Needed for a continuous form as only last record shows.
Me.Bookmark = varBookMark
I had just added a new record and then pressed the Requery button. The code works fine if I have not added a record. This is the first time I have added a record since amending the code.?
I expected the Me.Dirty to save the record, but both Me.BookMark and varBookMark have ? when printed in the immediate window?
What do I need to check for when having added new record(s) please?
The error is 3159 Not a valid bookmark, which I accept a ? would not be.