By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,078 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,078 IT Pros & Developers. It's quick & easy.

Error On Next Record If Already open..

P: 7
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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. redoLoop:
  3.     If Not rs.EOF Then
  4.         rs.Fields("current User ID") = ""
  5.         rs.Update
  6.        rs.MoveNext
  7.         curRecord = curRecord + 1
  8.         If rs.EOF Then
  9.             rs.MovePrevious
  10.             curRecord = curRecord - 1
  11.             If utreview = "Y" Then
  12.                MsgBox ("You have reached the end of the review.")
  13.                 Unload Me
  14.                 utreview = ""
  15.                 Exit Sub
  16.             End If
  17.         End If
  18.  
  19.         If typeReview = "IA" Then
  20.             If rs.Fields("current user id") <> "" Or rs.Fields("IA Review Date") <> "1/1/1900" Then GoTo redoLoop
  21.         ElseIf utreview = "Y" Then
  22.  
  23.         Else
  24.             If rs.Fields("current user id") <> "" Or rs.Fields("UT Date") <> "1/1/1900" Then GoTo redoLoop
  25.         End If
  26.  
  27.     End If
  28.     popRecord
  29.     Exit Sub
  30.  
Feb 22 '08 #1
Share this Question
Share on Google+
1 Reply


VBWheaties
100+
P: 145
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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. redoLoop:
  3.     If Not rs.EOF Then
  4.         rs.Fields("current User ID") = ""
  5.         rs.Update
  6.        rs.MoveNext
  7.         curRecord = curRecord + 1
  8.         If rs.EOF Then
  9.             rs.MovePrevious
  10.             curRecord = curRecord - 1
  11.             If utreview = "Y" Then
  12.                MsgBox ("You have reached the end of the review.")
  13.                 Unload Me
  14.                 utreview = ""
  15.                 Exit Sub
  16.             End If
  17.         End If
  18.  
  19.         If typeReview = "IA" Then
  20.             If rs.Fields("current user id") <> "" Or rs.Fields("IA Review Date") <> "1/1/1900" Then GoTo redoLoop
  21.         ElseIf utreview = "Y" Then
  22.  
  23.         Else
  24.             If rs.Fields("current user id") <> "" Or rs.Fields("UT Date") <> "1/1/1900" Then GoTo redoLoop
  25.         End If
  26.  
  27.     End If
  28.     popRecord
  29.     Exit Sub
  30.  
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(adMovePrevious) must return TRUE in order to move.
Now, lets say you want to Update. rs.Supports(adUpdate) needs to return True.
Wherever you are getting your error, you should place Supports before doing it.

Supports method:
http://www.w3schools.com/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.com/ado/prop_rs_locktype.asp

CursorType:
http://www.w3schools.com/ado/prop_rs_cursortype.asp
Feb 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.