Link to home
Start Free TrialLog in
Avatar of Angel02
Angel02

asked on

Write concflict in MS Access

I have a form in MS Access with  subform that has radio buttons and textboxes. When I try to modify the subform by changing the radio button or entering text into the textbox, it is displaying the "write conflict" error at the following line in one of the functions.

If Me.Dirty Then
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
 End If

Frankly, I have no idea about how it is validating. Please let me know what other details I need to provide.
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Try adding the following code to the  subform control's Enter event

Docmd.runcommand  acCmdSaveRecord
Usually that means you have some other event or code that started changing the record as well.  You will need to evaluated all code you have attached to the form.

ET
Avatar of Angel02
Angel02

ASKER

@mbizup
I added it but it did not change anything.

I first click on a "edit" button which loads the records (rows) that are to be edited. The fields values of the rows are populated into textboxes and radiobuttons.  Below is the function that does that:

Private Sub cmdEditRt_Click()
Dim strSource As String
'Steps
'1.Check if not exist
Dim rte As Integer
Dim Dt As Date
Dim flgOK As Boolean
   strSource = "SELECT tbl1.* FROM tbl1 " _
    & " WHERE (((Rt)=" & 0 & "))" _
    & " AND location= " & Location & ";"

Me.RecordSource = strSource

If Me.txtRt <> "" And Me.txtDate <> "" Then
    rte = txtRt
    Dt = txtDate
'Check if valid RT
     Select Case RtStatus(rte, Dt)
     
      Case 0
            MsgBox "not found!", , "Validation error"
      Case 1, 2
            flgOK = True
      Case 3
             MsgBox "started!", , "Validation error"
     Case Else
            If AppMode <> 4 Then
                MsgBox "already processed !", , "Validation error"
            Else 'just for diadnostic
                flgOK = True
            End If
     End Select
     If flgOK Then
         strSource = "SELECT tbl1.* FROM tbl1 " _
        & " WHERE ((Rt_Number)=" & rte _
        & " AND (finish_date)=#" & Format(Dt, "yyyy-mm-dd") & "#)" _
        & " AND location= " & Location & ";"

                Me.RecordSource = strSource
       End If
 
 Else ' rt is missing
        MsgBox "Please provide rt #!", , "Validation error"
 End If


End Sub

'********************

I then try to modify the textbox to update the row in the table. It is when I get the write conflict. The function that is called when I try to edit is below:
Public Sub ChangePayment()
If Me.fraPaymentType.Value = 0 Then
    Me.AmtTender_pay_cash = ""
    Me.AmtTender_pay_cash.SetFocus
    Me.AmtTender_pay_check = ""
    Me.AmtTender_pay_credit = ""
   
ElseIf Me.fraPaymentType.Value = 1 Then
    Me.AmtTender_pay_cash = ""
     Me.AmtTender_pay_check = ""
    Me.AmtTender_pay_credit = Me.SubTotal_forStop
ElseIf Me.fraPaymentType.Value = 2 Then
    Me.AmtTender_pay_cash = Null
    Me.AmtTender_pay_check = Me.SubTotal_forStop
    Me.AmtTender_pay_credit = ""
End If
If Me.Dirty Then
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 'FAILS HERE End If

End Sub

Is the cmdEditRt_Click function loacking the record? How do I check and if so what do I do to avoid?
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Angel02

ASKER

I placed Me.refresh immediately before the edit code as you mentioned. The runtime error now occurs at Me.Refresh in ChangePayment(). So this means it has to be saved even before getting to this function? I have Docmd.runcommand  acCmdSaveRecord at  subform Enter() like you suggested. So the record is being accessed somewhere in between?
Avatar of Angel02

ASKER

I wanted to add that this application used to work perfectly last week. I changed the connection string and it started throwing the error. I then changed the connection string back to the older one but it still would throw the write conflict.
What could be the cause?
Is your data stored in Access, SQL Server, or something else?
Avatar of Angel02

ASKER

Data is stored in MySQL.
It is accessed via Access.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Angel02

ASKER

I checked all the four tables related to the form and apparently none of them have even one bit field.