473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

update problem cannot see why

Is there anything wrong with my code?? Im just trimming the entries because a lot has spaces after them. after i click my button there is a runtime error saying that the update has affected too many rows.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command4_Click()
  2. Dim x As String
  3. Dim y As String
  4.  
  5.         Dim MyConn As ADODB.Connection
  6.         Dim MyRecSet As ADODB.Recordset
  7.         Set MyConn = New ADODB.Connection
  8.         MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\thesis\FINAL\FilipinoDict.mdb;"
  9.         MyConn.Open
  10.          Set MyRecSet = New ADODB.Recordset
  11.  
  12.     MyRecSet.CursorLocation = adUseClient
  13.     MyRecSet.Open "SELECT * FROM Dictionary", MyConn.ConnectionString, adOpenKeyset, adLockPessimistic
  14.         With MyRecSet
  15.  
  16.         Do Until .EOF
  17.             x = .Fields(0)
  18.             y = .Fields(1)
  19.  
  20.             .Fields(0).Value = RTrim(x)
  21.  
  22.             .Fields(1).Value = RTrim(y)
  23.  
  24.  
  25.             .MoveNext
  26.         Loop
  27.         End With
  28. End Sub
Thanks
Jan 28 '07 #1
2 845
willakawill
1,646 1GB
Hi, you are editing without updating. By the end of your while loop you have edited every row in your recordset and updated none.
Try it this way:
Expand|Select|Wrap|Line Numbers
  1. Dim bm As Variant
  2.  
  3. Do Until MyRecSet.EOF
  4.    bm = MyRecSet.Bookmark
  5.    MyRecSet.Fields(0).Value = RTrim(MyRecSet.Fields(0).Value)
  6.  
  7.    MyRecSet.Fields(1).Value = RTrim(MyRecSet.Fields(1).Value )
  8.    MyRecSet.Update
  9.    MyRecSet.Bookmark = bm
  10.  
  11.    MyRecSet.MoveNext
  12. Loop
Jan 28 '07 #2
Killer42
8,435 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1.    bm = MyRecSet.Bookmark
  2.    MyRecSet.Bookmark = bm
I'm curious, will. What's the reason for storing and then setting the bookmark?
Jan 30 '07 #3

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

Similar topics

7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
0
by: mr_wizard | last post by:
I posted a message yesterday on my difficulty in updating an Access table. Yesterday the error response was permission related. I've gotten past that, but still cannot update the table. XP Pro...
3
by: Roy | last post by:
Hi Access gurus, I have a A2K application.The data in the database is updated daily by a excel download.I have a master n related tables keyed in by a OrderID.I have a problem in updating data.If...
2
by: devine | last post by:
Hi All, I am trying to send an automatic email when an update has been made. My update statement will updates 6 fields, and dependant on one of the fields, I would like to send an email using CDO....
4
by: Ryan | last post by:
I've got a little bit of code that runs when you enter data in a datasheet view (which is a subform of the form you are in) if rst!DateReceived >= 30 Then Forms!DisposalRecords.Label90.Caption =...
5
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can...
60
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type?...
4
by: dougmeece | last post by:
Morning Everyone... I have a table that needs to be append to and also updated. All the fields in the table are populated with data from the text boxes and combo boxes on a form. The Date...
3
by: pinko1204 | last post by:
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx PHP1 <?php require_once 'header.php'; ?> <style type="text/css"> <!--
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.