W
Wade Arral
Guest
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
Continue reading...
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
Continue reading...