Error 3020 - Update or Cacel Updade wihout AddNew or Edit

Posted on 2012-08-28
Last Modified: 2012-08-28
I am consistentlly getting the above error on  routin that was not changed before.
Below I am sending in a screenshot of the code.
Could be that the T01 table is modified elsewhere?
Question by:jirdeaid
    LVL 61

    Accepted Solution

    Try placing the Edit line in the same IF-Then block as the statements where that recordset is bieng edited and updated -- right after the following line:

    IF Found Then
              ... etc - code that does the edits
    End if

    Author Closing Comment

    It worked.

    I still can't understand why it worked before and, suddenly stopped working... anyway, in the future I'll do this new way.

    LVL 61

    Expert Comment

    I believe your method would work with an AddNew statement.

    The difference with .Edit is that you need to be pointing to a specific record for the Edit to take place.  Operations that involve moving to different records may 'cancel' an edit.

    I'm not sure that the exact placement of your .Edit is critical (it is my own preference to have it grouped snugly with the actual edits and updates just for code organization), but it should be placed AFTER whatever code you have to take you to the record that needs to be edited.

    As a side note, when posting code - if you post copy/pasted code as text instead of screenshots, it makes it easier for us to copy your code into our comments for better/more precise responses.

    Author Comment

    Many thanks for the help.

    Also for the code hint: I will start pasting the code instead of screenshotting it. It did it only to eveidence the problem with the messages issued by the VBA subsystem and make easier to show the problem. Maybe I should do both...
    LVL 61

    Expert Comment

    That would work well -- or even if you use code snippets, mention the problematic line number(s).  Whatever is easiest :-)

    Btw, I got the email notifs on your other question, but can't download .accdb format files at the moment.  If no one else jumps in, I'll take a look at it later today from a computer that I have Access 2010 installed on.

    Author Comment

    Thanks for the help. The other question is still pending.
    The suggestion did not work and I am still scratching my head on how to correctly put a form control source correct so it shows the result of a query (recordset).

    It on Form F0304. The problem is that, even the current approach (using a single complicated SQL) is not so good.

    In reality there will be too many fields plus and /or options and even double metaphone, so I should, in reality, be able to construct an RST by parts and the either expand it with new records (I would use the .AddNew) ir set up more filters (a query on a query on query.... - ideally a query that has a source that its itself, do you follow?

    Anyway, I updated the database and uploaded it again and, this time, inseted the relevant code as actual text.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now