Results 1 to 6 of 6
  1. #1
    user9 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2013
    Location
    US
    Posts
    43

    Save Record button - VBA to move form out of edit mode

    I have a button used to append form changes to a table, which works as expected.



    However, after clicking the form remains in edit mode (the pencil icon) and I cannot exit the form or go to a new record without getting a Write Conflict error.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    As a rule a form should either be bound to a table or code used to change the data, not both.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    user9 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2013
    Location
    US
    Posts
    43
    Quote Originally Posted by pbaldy View Post
    As a rule a form should either be bound to a table or code used to change the data, not both.
    It's bound to a table and updates as expected on click, but doesn't exit edit mode. If there's a way to exit the edit mode without VBA, I'm open to it.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If it's bound to the table, why are you making data changes in code? You can try

    If Me.Dirty Then Me.Dirty = False

    but you will get the same error if you're changing data in the background that's displayed on the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    user9 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2013
    Location
    US
    Posts
    43
    Ok so the context:

    I have a design for a multi-user database:
    1. Form A is used to update Table A and Table B (simultaneously On Click)
    2. Form B is used to review Table B, approve records, then delete them from Table B

    Changes made in Form A are reflected in Form B. Approving these changes sends the data to the appropriate tables. However, the form remains in edit mode and I get the Write Conflict error.

    If this is a design error, would you recommend a different approach?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Access is protecting you from yourself. It senses that data you have open on the form has been changed behind the scenes. The error you get is how it warns you that it happened. The solution is to either let the bound form change the data and get rid of the code, or let the code change the data and make the form unbound (removing the form's record source and the textbox control sources).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 21
    Last Post: 08-05-2013, 06:23 AM
  2. Control Button to toggle edit mode
    By Leonidsg in forum Programming
    Replies: 2
    Last Post: 03-19-2013, 06:53 PM
  3. Replies: 3
    Last Post: 10-08-2012, 08:40 AM
  4. Replies: 8
    Last Post: 09-27-2012, 11:12 AM
  5. Replies: 2
    Last Post: 09-01-2011, 10:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums