473,396 Members | 2,052 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,396 software developers and data experts.

Updating table with recordSource - Error 3020

Dear Community,

I am trying to update all entries from table "tbValve" when a specific criteria is verified (regarding Fabric value).
When implementing the code bellow, an error 3020 occurs (Update or CancelUpdate without AddNew or Edit).
Need help because I cannot understand why is this happening.
Thank you!!

Expand|Select|Wrap|Line Numbers
  1.         Dim rs As DAO.Recordset, query1 As String
  2.         query1 = "Select TagValve from tbValve Where Fabric = '" & cbEdit.Column(1) & "'"
  3.         Set rs = CurrentDb.OpenRecordset(query1)
  4.         With rs
  5.         If Not .BOF And Not .EOF Then 
  6.         .MoveFirst
  7.         .Edit
  8.         Do While Not rs.EOF
  9.         !TagValve = Replace(cbEdit.Column(0), cbEdit.Column(0), TagValve)
  10.         .MoveNext
  11.         Loop
  12.         .Update
  13.         .Close
  14.         End If
  15.         End With
  16.         Set rs = Nothing
Sep 12 '17 #1

✓ answered by Rabbit

You are only editing the first row and then updating the last row.

You have to call edit and update on each row. Move them inside the loop.

Aside from that, it's probably better to run an update query rather than looping through a recordset.

4 3014
Rabbit
12,516 Expert Mod 8TB
You are only editing the first row and then updating the last row.

You have to call edit and update on each row. Move them inside the loop.

Aside from that, it's probably better to run an update query rather than looping through a recordset.
Sep 12 '17 #2
Hello Rabbit,

Thank you for your answer.
Even inside the loop, the same error occurs.
I will try to implement the update query.
Ty

Regards
Sep 12 '17 #3
Rabbit
12,516 Expert Mod 8TB
It would help to see where you put it in the revised code. The update has to be before the MoveNext. Otherwise you run into the same problem of editing one row but updating a different row.
Sep 12 '17 #4
My inattention! You are absolutely right. The problem is now solved with your advice.
Thank you very much.

Best regards.
Sep 12 '17 #5

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

Similar topics

3
by: LineVoltageHalogen | last post by:
Greeting All, I have a stored proc that dynamically truncates all the tables in my databases. I use a cursor and some dynamic sql for this: ...... create cursor Loop through sysobjects and...
5
by: ColinWard | last post by:
Hi. I have a contacts form with an unbound dropdown box and a bunch of bound controls relating to the contact. When I load the form, I want all the controls to be empty until I select a name from...
0
by: Trevor Best | last post by:
Access 2002 MDB -> SQL Server 2000 - ODBC Linked tables. B4 we start, this is not occurring in a recordset operation and yes I googled, even found my own fix, which I already use...
6
by: cyoung311 | last post by:
I'm trying to do an automatic update of one table from another through a form. Basically, when a selection is made for an item, in this case a particular workshop, I want to get the associated...
4
by: deko | last post by:
I'm trying to import an Excel Spreadsheet into an Access Table but sometimes things get buttered up if the spreadsheet does not have the right columns. So I want to drop the Access table and...
3
by: stuart.medlin | last post by:
I have an Access 97 application that has a basic form (Transcript) and subform. The subform has a query as a recordsource that returns records from a table: SELECT DISTINCTROW Transcript.NCID,...
2
by: tomash | last post by:
Hi! I ve got two tables in Access 2007. I want to update a field of DataTable from another table, DataSumTable when two of their fields equals. ( the fields : Name and Period) I tried this...
4
by: AlexNunley | last post by:
I've adopted a moderately sized (65k records) active use database (Access 2000, Windows XP). One of the most commonly used forms is whats called the RMA generation field, used to add claim...
57
thelonelyghost
by: thelonelyghost | last post by:
Just searched google and this website but I couldn't come up with an answer to this. Basic Information Software: Microsoft Access 2000 OS: Windows XP Professional SP3 Problem: Error 3008...
1
by: AndyB2 | last post by:
Using Access 2010 Windows 7 I'm sure this is a simple VBA Gramer problem. I am attempting to update a table. Below is the code and I'm getting the error on the line BOM("Level") = 1, Line...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.