Error On Next Record If Already open..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cbanks
    New Member
    • Jan 2008
    • 7

    Error On Next Record If Already open..

    Hello Ladies/Gents, im in need of some serious help here.. I have a tool that allows users to view information on a form and make changes to recordsets. This tool has buttons that allow a user to cruise to the next or previous record. The problem i am having is when they click next record it moves to the next record and checks to see if the record is stamped as open. If it is stamped as open, meaning opened by another user, then it will continue to proceed to the next record until it reaches a record not already stamped open. I will post the code below Im using for next the previous is the same except for it moves previous. When they click next or previous even though they are not changing any information, just checking to see if the record is open, the user who was looking at that record gets an error when trying to click next record. Its an error relating to the row was modified outside of cursor. My question is how am I supposed to allow them to proceed through records without getting this error? They are not modifying the record just looking to see if its stamped open.
    thanks for your help.

    Code:
    redoLoop:
        If Not rs.EOF Then
            rs.Fields("current User ID") = ""
            rs.Update
           rs.MoveNext
            curRecord = curRecord + 1
            If rs.EOF Then
                rs.MovePrevious
                curRecord = curRecord - 1
                If utreview = "Y" Then
                   MsgBox ("You have reached the end of the review.")
                    Unload Me
                    utreview = ""
                    Exit Sub
                End If
            End If
    
            If typeReview = "IA" Then
                If rs.Fields("current user id") <> "" Or rs.Fields("IA Review Date") <> "1/1/1900" Then GoTo redoLoop
            ElseIf utreview = "Y" Then
                
            Else
                If rs.Fields("current user id") <> "" Or rs.Fields("UT Date") <> "1/1/1900" Then GoTo redoLoop
            End If
        
        End If
        popRecord
        Exit Sub
  • VBWheaties
    New Member
    • Feb 2008
    • 145

    #2
    Originally posted by cbanks
    Hello Ladies/Gents, im in need of some serious help here.. I have a tool that allows users to view information on a form and make changes to recordsets. This tool has buttons that allow a user to cruise to the next or previous record. The problem i am having is when they click next record it moves to the next record and checks to see if the record is stamped as open. If it is stamped as open, meaning opened by another user, then it will continue to proceed to the next record until it reaches a record not already stamped open. I will post the code below Im using for next the previous is the same except for it moves previous. When they click next or previous even though they are not changing any information, just checking to see if the record is open, the user who was looking at that record gets an error when trying to click next record. Its an error relating to the row was modified outside of cursor. My question is how am I supposed to allow them to proceed through records without getting this error? They are not modifying the record just looking to see if its stamped open.
    thanks for your help.

    Code:
    redoLoop:
        If Not rs.EOF Then
            rs.Fields("current User ID") = ""
            rs.Update
           rs.MoveNext
            curRecord = curRecord + 1
            If rs.EOF Then
                rs.MovePrevious
                curRecord = curRecord - 1
                If utreview = "Y" Then
                   MsgBox ("You have reached the end of the review.")
                    Unload Me
                    utreview = ""
                    Exit Sub
                End If
            End If
    
            If typeReview = "IA" Then
                If rs.Fields("current user id") <> "" Or rs.Fields("IA Review Date") <> "1/1/1900" Then GoTo redoLoop
            ElseIf utreview = "Y" Then
                
            Else
                If rs.Fields("current user id") <> "" Or rs.Fields("UT Date") <> "1/1/1900" Then GoTo redoLoop
            End If
        
        End If
        popRecord
        Exit Sub
    One constructive critique: GoTo statements make code unreadable or difficult to debug.

    You can use .SUPPORTS to see if the various operations needed are allowed. This will then tell you what you should do to correct your problem.

    For example, let's say you are going to MovePrevious, rs.Supports(adM ovePrevious) must return TRUE in order to move.
    Now, lets say you want to Update. rs.Supports(adU pdate) needs to return True.
    Wherever you are getting your error, you should place Supports before doing it.

    Supports method:
    http://www.w3schools.c om/ado/met_rs_supports .asp

    Now, lets say you cant move or update. This is where the LockType and CursorType properties become relevent. Based on what you are not allowed to do, you will have to adjust your locktype and cursortype properties before opening the recordset in order to be able to do it.

    Locktype:
    http://www.w3schools.c om/ado/prop_rs_locktyp e.asp

    CursorType:
    http://www.w3schools.c om/ado/prop_rs_cursort ype.asp

    Comment

    Working...