Error 3159: Not a valid bookmark

Alistair J

Registered User.
Local time
Today, 20:34
Joined
Jun 25, 2008
Messages
30
Hi

I have a button on a subform that opens another form and when that form closes I want the record showing on the subform to be the same as when left. My solution has been to put a bit of code in the button opening the form to mark a check box control called 'current' and then to put the following code in the 'On Close' event of the form being opened:

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Client Worker Link", dbOpenDynaset)
rs.Edit
rs.Update
rs.FindFirst "[current] = True"
If rs.NoMatch = True Then
rs.FindLast "[current] = False"
If rs.NoMatch = True Then
Exit Sub
Else
MsgBox ("Please note that when you return to the Client Details form," & Chr(13) & "the worker showing will be the last worker entered for this client." & Chr(13) & "Please use the navigation controls to create a new worker record.")
End If
End If

[Forms]![Client Details]![clientworkerlink].Form.Bookmark = rs.Bookmark
rs.Close
[Forms]![Client Details]![clientworkerlink].Form![current] = False
[Forms]![Client Details]![clientworkerlink].Form.Recalc

This appeared to work OK until I started getting the Error 3159: Not a valid bookmark. The only references to this error I can find on the internet seem to suggest that I have a corrupted database, but I've compacted & repaired the database several times and I don't get the error at any other point so I was wondering if my code is rubbish?

Incidentally, the code still seems to work in the sense that the record showing when I return to the subform is still the one that was showing when I left, so should I just trap the error and not worry about it, or is that foolhardy?
 
Hi again,

Please ignore the above. I discovered that if I commented everything out but the recalc line, I got the result I wanted without using the code. The reason I had it there in the first place was that I had copied it from another database where I was doing the same thing because doing the recalc seemed to reset the records on the subform to the first record so I needed a way to navigate back to the record I wanted. That was in 2007 and the same thing does not seem to happen in 2003! Oh well....
 

Users who are viewing this thread

Back
Top Bottom