473,395 Members | 1,996 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,395 software developers and data experts.

Run-time error 3020; Update or CancelUpdate without AddNew or Edit

49
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 21. I'm sure lines 22, 25, and 27 will have the same issue.


Expand|Select|Wrap|Line Numbers
  1. Private Sub CB_RunQueryPrintReport_Click()
  2.  
  3. Dim stDocName As String
  4. Dim Filename As String
  5. Dim i, RC, X As Integer
  6. Dim MyDB As DAO.Database
  7. Dim REQ, BOM As DAO.Recordset
  8. Dim UDI As DAO.Recordset2
  9. 'Dim BOM As DAO.Recordset
  10. Dim CurrSpecies As String
  11.  
  12. Set MyDB = DBEngine.Workspaces(0).Databases(0)
  13. Set REQ = MyDB.OpenRecordset("Tbl_REQData", DB_OPEN_TABLE)
  14. Set UDI = MyDB.OpenRecordset("Tbl_UDIData", DB_OPEN_TABLE)
  15. Set BOM = MyDB.OpenRecordset("Tbl_BOM_Level", DB_OPEN_TABLE)
  16.  
  17. DoCmd.Hourglass True
  18. DoCmd.SetWarnings False
  19.  
  20. i = 0
  21. BOM("Level") = i
  22. BOM("Prev Level") = i
  23. DoCmd.OpenQuery "Qry_FindPanelParts"
  24. For i = 1 To 7
  25.     BOM("Level") = i
  26.     DoCmd.OpenQuery "Qry_FindPanelPartsNextLevelDown"
  27.     BOM("Prev Level") = i
  28. Next i
  29.  
  30. etc... error is above:
  31.  
Jan 7 '13 #1

✓ answered by Seth Schrock

In order to edit a recordsource in VBA, you must use the Edit method (as the error states). So what you need is something like:
Expand|Select|Wrap|Line Numbers
  1. With BOM
  2.      .Edit
  3.      !Level = i
  4.      !Prev Level = i
  5.      .Update
  6. End With
This replaces lines 21, 22, 25, & 27.

Here is a link that explains the Edit method: Recordset.Edit Method

1 20218
Seth Schrock
2,965 Expert 2GB
In order to edit a recordsource in VBA, you must use the Edit method (as the error states). So what you need is something like:
Expand|Select|Wrap|Line Numbers
  1. With BOM
  2.      .Edit
  3.      !Level = i
  4.      !Prev Level = i
  5.      .Update
  6. End With
This replaces lines 21, 22, 25, & 27.

Here is a link that explains the Edit method: Recordset.Edit Method
Jan 7 '13 #2

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

Similar topics

1
by: James | last post by:
Hi, I would like to run a custom script on a linux box via a button on a php page (php webpage hosted on the same linux box). Is this possible? If so , can you give me a pointer in the right...
5
by: hakim | last post by:
Hi, I need some information ? How I can run my project (Php) on CGI. Thanks.
2
by: Dica | last post by:
i'm just learning java now, so this might be obvious, but not to me. my app needs to do two things: (1) connect to and fetch a list of tasks for a user from a web service (2) connect to mapquest...
10
by: Frog | last post by:
Hi, i'm not a programmer so I have a very stupid question. I'm trying to make a practical script. I need to run an executable program in it but i can't get it to work. Maybe someone here can...
3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
2
by: Eric Woudenberg | last post by:
I just installed a Python 2.3.4 Windows binary on a friend's WinXP machine (because the latest Cygwin-provided Python 2.3 build leaves out the winsound module for some reason). When I try and...
4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
9
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. ...
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
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
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.