Wrox Programmer Forums
|
VB Components Issues specific to components in VB.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2006, 01:12 PM
Authorized User
 
Join Date: Mar 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default vba recodeset update (Excel)

I use the following to update a recordset field value if it's found to be Null. When processing
the Update statement, I get the following error.

     "Row cannot be located for updating" Some values may have been updated since last read.

My code...


Set rsset = New ADODB.Recordset
rsSet.CursorType = adOpenStatic
rsEdit.LockType = adLockOptimistic
rsEdit.Open "SELECT * FROM Customers"


rsSet.Movefirst
   While not rsSet.EOF
      If isnull(rsSet("Divide") = True then
              rsSet.fields("Divide") = 8844
              rsSet.fields("Codename") = "NoName"
          rsSet.Update ' >>>>>>>>> I get the above error at this step!!
          rsEdit.MoveFirst
      End if
   Wend

Just before the update statement. I perform a debug.print rsSet.fields("Divide"), rsSet.fields("Codename")
to find that the values have been changed to the new value 8844 & NoName respectively.

Updating & advancing to the next record seems to be a problem.


Any suggestions for resolving my update issue?





 
Old October 20th, 2006, 09:17 AM
Authorized User
 
Join Date: Mar 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Correction of code...

I use the following to update a recordset field value if it's found to be Null. When processing
the Update statement, I get the following error.

     "Row cannot be located for updating" Some values may have been updated since last read.

My code...


Set rsSet = New ADODB.Recordset
rsSet.CursorType = adOpenKeySet
rsSet.LockType = adLockOptimistic
rsSet.Open "SELECT * FROM Customers"


rsSet.Movefirst
   While not rsSet.EOF
      If isnull(rsSet("Divide") = True then
              rsSet.fields("Divide") = 8844
              rsSet.fields("Codename") = "NoName"
          rsSet.Update ' >>>>>>>>> I get the above error at this step!!
          rsSet.MoveNext
      End if
   Wend

Any suggestions would be helpfull







Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA and Update Query Revisited eusanpe Access VBA 12 June 18th, 2008 06:21 AM
SOLVED...VBA and Update Query eusanpe Access VBA 8 June 2nd, 2008 08:48 AM
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Converting excel data to Access using excel VBA ShaileshShinde VB Databases Basics 1 April 26th, 2006 07:57 AM
Excel VBA to SQL & back to VBA edesousa Excel VBA 1 June 1st, 2004 02:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.