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:
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?