none
Update or CancelUpdate without AddNew or Edit

    Question

  • I created a form in Access 2007, based on a table with no sorting,
    filtering - it just reads the table which I populated manually before
    designing the form.
    Today I tried changing the data in some of the fields on the form and I get
    an error message: "Update or CancelUpdate without AddNew or Edit"
    The queries I found posted online all seem to assume that someone is using a
    recordset rather than populating the form from the table.
    Properties on the form allow additions, deletions, edits and filters. Data
    Entry is no.
    I do have a subform on the form but there are no problems with it.
     
    What can I check to see what is causing this error message?
     
     

    Michele
    Thursday, June 16, 2011 3:24 PM

Answers

  • Hi Michele,

    I found this:

    .....try adding explicit saves to your
    code before anything that could require the record to be saved, such as a
    requery, filter, orderby, reassigned recordsource, moving record, closing
    form, etc, etc. The explicit save does help avoid errors. We use:
    If Me.Dirty Then
    Me.Dirty = False
    End If
    because that code is explicit about which form to save the record in.

    written by Allen Browne in a post at

    http://www.pcreview.co.uk/forums/update-cancelupdate-without-addnew-edit-t1150554.html

     


    Bob Fitz BizSoftware
    • Proposed as answer by Bruce Song Thursday, June 23, 2011 11:34 AM
    • Marked as answer by Bruce Song Tuesday, July 05, 2011 11:32 AM
    Thursday, June 16, 2011 9:35 PM
  • I created a form in Access 2007, based on a table with no sorting,
    filtering - it just reads the table which I populated manually before
    designing the form.
    Today I tried changing the data in some of the fields on the form and I get
    an error message: "Update or CancelUpdate without AddNew or Edit"
    The queries I found posted online all seem to assume that someone is using a
    recordset rather than populating the form from the table.
    Properties on the form allow additions, deletions, edits and filters. Data
    Entry is no.
    I do have a subform on the form but there are no problems with it.
     
    What can I check to see what is causing this error message?

    Have you got any code behind the form at all?  What about macros executed by events?  If so, please post the code/macro details.  I think I have seen this before, and it had to do with modifying values in code in the wrong event.
    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html
    • Proposed as answer by Bruce Song Thursday, June 23, 2011 11:34 AM
    • Marked as answer by Bruce Song Tuesday, July 05, 2011 11:32 AM
    Thursday, June 16, 2011 10:00 PM

All replies

  • Hi Michele,

    I found this:

    .....try adding explicit saves to your
    code before anything that could require the record to be saved, such as a
    requery, filter, orderby, reassigned recordsource, moving record, closing
    form, etc, etc. The explicit save does help avoid errors. We use:
    If Me.Dirty Then
    Me.Dirty = False
    End If
    because that code is explicit about which form to save the record in.

    written by Allen Browne in a post at

    http://www.pcreview.co.uk/forums/update-cancelupdate-without-addnew-edit-t1150554.html

     


    Bob Fitz BizSoftware
    • Proposed as answer by Bruce Song Thursday, June 23, 2011 11:34 AM
    • Marked as answer by Bruce Song Tuesday, July 05, 2011 11:32 AM
    Thursday, June 16, 2011 9:35 PM
  • I created a form in Access 2007, based on a table with no sorting,
    filtering - it just reads the table which I populated manually before
    designing the form.
    Today I tried changing the data in some of the fields on the form and I get
    an error message: "Update or CancelUpdate without AddNew or Edit"
    The queries I found posted online all seem to assume that someone is using a
    recordset rather than populating the form from the table.
    Properties on the form allow additions, deletions, edits and filters. Data
    Entry is no.
    I do have a subform on the form but there are no problems with it.
     
    What can I check to see what is causing this error message?

    Have you got any code behind the form at all?  What about macros executed by events?  If so, please post the code/macro details.  I think I have seen this before, and it had to do with modifying values in code in the wrong event.
    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html
    • Proposed as answer by Bruce Song Thursday, June 23, 2011 11:34 AM
    • Marked as answer by Bruce Song Tuesday, July 05, 2011 11:32 AM
    Thursday, June 16, 2011 10:00 PM
  • I did a compact/repair and that seems to have fixed it. There is a lot of
    code updating one field based on the contents of another, etc, but the
    errors wouldn't let me change any field. Now it is working. Very
    frustrating! - but thanks for your help.
    Michele
     
     
    "Dirk Goldgar" <=?utf-8?B?RGlyayBHb2xkZ2Fy?=> wrote in message
    news:24a243ff-6e45-4b61-b626-654e4f76ba19...
    I created a form in Access 2007, based on a table with no sorting,
    filtering - it just reads the table which I populated manually before
    designing the form.
    Today I tried changing the data in some of the fields on the form and I get
    an error message: "Update or CancelUpdate without AddNew or Edit"
    The queries I found posted online all seem to assume that someone is using a
    recordset rather than populating the form from the table.
    Properties on the form allow additions, deletions, edits and filters. Data
    Entry is no.
    I do have a subform on the form but there are no problems with it.
     
    What can I check to see what is causing this error message?
     
    Have you got any code behind the form at all? What about macros executed by
    events? If so, please post the code/macro details. I think I have seen
    this before, and it had to do with modifying values in code in the wrong
    event.
     
    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html
     
     

    Michele
    Friday, June 17, 2011 9:26 PM
  • Sometimes I find that problems like this one can be caused by using the AfterUpdate or AfterInsert Events instead of the corresponding BeforeUpdate or BeforeInsert events. If you get this problem again, try the latter and see if that helps.
    Matthew Slyman M.A. (Camb.)
    Friday, June 17, 2011 10:01 PM
  • I did a compact/repair and that seems to have fixed it. There is a lot of
    code updating one field based on the contents of another, etc, but the
    errors wouldn't let me change any field. Now it is working. Very
    frustrating! - but thanks for your help.

    That sounds like there was some corruption in your database.  Although the compact/repair fixed it, it may be a good idea to decompile the database, compact it, and recompile it.  Hopefully, that will eliminate any lingering corruption in your VB project.
    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html
    Sunday, June 19, 2011 1:30 PM
  • I got the same error.  I fixed it by adding thisRecordSet.Edit prior to the command that caused it then thisRecordSet.Update after the command. 
    Monday, May 07, 2012 10:16 PM