Results 1 to 2 of 2
  1. #1
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92

    Get Write Conflict message due to my VBA code

    Hey everyone. I'm receiving a Write Conflict error every time some code runs in the background that is tied to one of my buttons on a Form I've created. There is a lot of code tied to that button -- it's doing a bunch of calculations, based on information that a user types into the form. (It's calculating an employee's time sheet.) One thing I need it to do during the calculations is to write some data into the Table the form is based on, and because of that, I think that may be why I'm receiving the error. At least that's my guess based on the little info I've been able to find online about this error.

    Here's the error message:
    Click image for larger version. 

Name:	WriteConflict.png 
Views:	8 
Size:	9.0 KB 
ID:	31125

    There is no other user. I'm doing this on Access on my home computer and no one else has access to the file.

    If I had to guess, I'd say this is probably the code that is cause this error to appear:
    Code:
    Sub Show_MP_Money(Amount, Day_Of_Week, Time_of_Day)
    
    ' This sub inputs the dollar amount owed for a meal penalty in the correct field in the T_Timecards table
    
    Dim rstT_Timecards As Recordset
    Dim MP1Amt As String
    Dim MP2Amt As String
    Dim MP3Amt As String
    
    MP1Amt = "D" & Day_Of_Week & "_MP1Amt"
    MP2Amt = "D" & Day_Of_Week & "_MP2Amt"
    MP3Amt = "D" & Day_Of_Week & "_MP3Amt"
    
    Set rstT_Timecards = CurrentDb.OpenRecordset(Name:="T_Timecards", Type:=RecordsetTypeEnum.dbOpenDynaset)
    
    With rstT_Timecards
    
        If Time_of_Day = 0 Then
            .Edit
            .Fields(MP1Amt) = Amount
            .Update
        ElseIf Time_of_Day = 1 Then
            .Edit
            .Fields(MP2Amt) = Amount
            .Update
        ElseIf Time_of_Day = 2 Then
            .Edit
            .Fields(MP3Amt) = Amount
            .Update
        End If
        
    End With
    
    rstT_Timecards.Close
    Set rstT_Timecards = Nothing
    
    End Sub
    Is there any way that I can make this go away? If I was to create a Query and write the data to that inside of the Table directly, do you know if that would cause this error to go away? If not, what if I wrote this data to a different Table, meaning not the one tied to this Form?

  2. #2
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    Actually -- after thinking about it more, I realized that I could create some global variables and store the values in there, rather than writing them to the Table. So... never mind. Sorry for the unneeded post.

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

Similar Threads

  1. Replies: 21
    Last Post: 09-16-2016, 08:44 PM
  2. Write Conflict?
    By batowl in forum Forms
    Replies: 4
    Last Post: 11-13-2014, 12:38 PM
  3. Write Conflict Help
    By jbailey4545 in forum Access
    Replies: 5
    Last Post: 01-24-2014, 02:25 PM
  4. Write Conflict
    By sah in forum Forms
    Replies: 8
    Last Post: 04-25-2012, 07:19 AM
  5. Write Conflict Error Message
    By AKQTS in forum Forms
    Replies: 2
    Last Post: 07-27-2010, 09:57 AM

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