locked
Not a valid bookmark happens once then code works RRS feed

  • Question

  • I have a database for customer quotes. I have a "move line up" and "move line down" button - which worked in an older version of the database, but I've had to change some things and release a new version. My problem is when you click the move up or down button, I get error message "Not a valid bookmark" - but when you hit OK, the code then works correctly and I can move the lines up and down with the buttons with no errors. 

    Why would this error happen just the first click, but then work correctly thereafter?

    Private Sub btnMoveDown_Click()
            
        Dim db As Database, rs As Recordset
        Dim frm As Form
        Dim bottomNum%, TopNum%
        Dim Bkmark$

        Set db = DBEngine(0)(0)
        Set frm = Me![QuoteLines Table subform].Form
        Set rs = frm.RecordsetClone
        If rs.RecordCount = 0 Then
            Exit Sub
        End If
        MsgBox "Made it here 1"
        rs.Bookmark = frm.Bookmark
        MsgBox "Made it here 2"
        TopNum = rs("SubLineNo")
        rs.Bookmark = frm.Bookmark
        rs.MoveNext
        If rs.EOF Then
            Exit Sub
        Else
            Bkmark = rs.Bookmark
            bottomNum = rs("SubLineNo")
            rs.Edit
            rs("SubLineNo") = TopNum
            rs.Update
        End If
        rs.Bookmark = frm.Bookmark
        rs.Edit
        rs("SubLineNo") = bottomNum
        rs.Update


        frm.Requery
        frm.Bookmark = Bkmark
    End Sub

    Wednesday, July 3, 2019 6:10 PM

All replies

  • Hi,

    This forum is discussing and asking questions about the vb.net,your code is vb6 or vba?You can ask in the appropriate forum.

    VB6

    VBA

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Alex-KSGZ Thursday, July 4, 2019 2:31 AM
    Thursday, July 4, 2019 2:28 AM