Results 1 to 12 of 12
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281

    How to Update a Bound Table Without Getting a Write Conflct Error

    Greetings Experts ~

    First - please allow me to apologize for the ambiguity of my thread title - Just wan't sure how to phrase this one.

    Ok, here is my setup:

    What I have is a form bound to a linked SQL table - which, of course is updated with changes made to the form.

    Where I encounter my issue is when the user completes their changes and clicks 'Submit'

    The click event has an Update query which places a timestamp in an unbound field.

    The table has an ID field; and as I understand from my research, updates the moment the record is entered into the form.

    I further understand the event of updating the ID field also places a 'lock' on that record

    Thus, when the user finishes with their changes and clicks 'Submit' - They receive the dreaded 'Write Conflict Error' Seemingly due to the Update Query.

    I have tested this theory and the Update Query does appear to be the issue as with it commented out - the Write Conflict Dissappears.

    So... What I am now trying to figure out is how to update the record with a timestamp without causing a Write Conflict.

    I've tried setting the Dirty Property to True/False in a few locations - That hasn't worked yet.



    I could place a hidden control (textbox) on the form and simply update the control and forego the Update Query - But is this the best way?

    And lastly, I do have Bit fields (Yes/No - True/False) which do not have a default value and thus are set to Null until the record is updated

    I also read where this could cause the issue I'm experiencing as well.

    Anyway, sorry for the disertation, but I hope this puts you right in the driver seat of what I'm dealing with.

    As for Code - I wasn't sure what to post for this question - but I will provide anything you need to help you help me

    Thanks Everyone...

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    your title says bound, your text says unbound.
    why unbound and an update query?
    can you not just edit the record directly (bound) along with the datestamp?

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    places a timestamp in an unbound field.
    bind that field on the form; don't show if preferred. In click event, first write time stamp to control/field. Rest of code (if there is any) can run, including If Me.Dirty Then Me.Dirty = False
    You should neither use or need update sql for a bound form in most cases.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    RanMan - Micron, Glad you guys are out there...

    So I kinda figured this would be hard to describe - but your insights will help me narrow down my issue a little better.

    Yes, the form is bound - however there is one field in the table (the timestamp field) that has no form control associated with it,

    and thus (to my understanding is an unbound field). It receives its value through the click event using an update qry.

    All the other fields receive their values, of course, through the bound controls on the form.

    Micron ~ If I understand your suggestion correctly, you would place a control on the form,

    bind it to the (in this case) timestamp field, then simply update the control on the click event?

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Yes. You can do so as Me.txtTimeStamp = Now(), then whatever action you need to take should update the field. To have a form based on 11 bound fields but have a field in the same table (thus related to the same record) as the 12th field but not bound makes no sense to me. Perhaps I am missing something though, like the timestamp field isn't where I think it is. I think ranman's 2nd question is implying the same approach, just expressed differently.

    Keep in mind that there's more than 1 way to update/write a record: navigating off the record, clicking on main form (the update will happen to the subform), closing form, vba code - so you need to update the control first. Also, I just tested if Now() can be the default value for a table field because I couldn't recall. Seems that it can, so your solution may be as simple as setting table default to Now(), bind the control to it and forget it if you're not looking to set a particular value.

  6. #6
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    The initial design of this app was to simply update records via a userform - The idea to timestamp the update came later.
    And, since the timestamp was not an updateable field there was no control alloted for it as it was set at runtime.
    Well, I have now added a control to the form - Set its .visible prop to No - bound it to the timestamp field and set it to: Now() @ runtime
    Problem solved
    Thanks Guys - Very much!

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    So this timestamp value is modified every time a record is edited?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    not if it is the default value, no? That only applies to a new record?

  9. #9
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    Hey June ~

    Users will go through each record and make updates. At the conclusion they click Submit which timestamps their changes, and moves to the next record thus saving their changes

    Each time they go through this process and click submit that record is timestamped. If they update the same record more than once the timestamp will reflect the last time it was updated.

    I hope that makes sense...

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    bound it to the timestamp field and set it to: Now() @ runtime
    I guess by runtime you mean when some event like the button click occurs, and that you're using code to set the bound control value to Now(). You should be OK with that, but I guess I forgot the intent was for updating as well so just want to make sure you know that table default value won't work for updates.

  11. #11
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    Hey Micron ~ Yeah, because individual records might be updated multiple times I want to add the timestamp @ runtime (yes, when the user clicks the submit button) to always add the latest time when a record was updated - so, I'm not using a table default value for this one

    Thank You, Micron

    On a footnote - I still can't get rid of the Write Conflict Error
    So I'm going to post the code and beg for help - I haven't been this frustrated in quite a long time...

    Stay tuned Please!!! lol

  12. #12
    Join Date
    Apr 2017
    Posts
    1,679
    I think it will be better that instead of having button event updating the timestamp control you use BeforeUpdate event of form to do this. Then the timestamp will be updated regardless of method used to save the record. In case all the button currently does is to set timestamp and save the record, you even can consider removing the button then!

    As about Write Conflict error, it is difficult to say anything for sure without an example DB uploaded here, but a couple of possible reasons may be:
    1. The timestamp field in your table is calculated one;
    2. You use an Update query for table with autonumeric field, and included this field into query.

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

Similar Threads

  1. UPDATE 3073 error trying to update a table field
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 10-11-2018, 05:11 PM
  2. Replies: 10
    Last Post: 05-17-2017, 02:06 PM
  3. best way to write update query in vba
    By tagteam in forum Access
    Replies: 5
    Last Post: 01-04-2017, 04:36 PM
  4. Write Conflict When Trying To Update Table
    By jo15765 in forum Access
    Replies: 20
    Last Post: 09-02-2016, 09:12 AM
  5. Replies: 3
    Last Post: 08-06-2012, 03:29 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