Since last week tuesday (18-9-2018), Access sometimes freezes when saving data to the MS SQL back-end database.
It mostly occurs on moments were multiple people are using the application. This has never given any problems untill last week. So thats a bit strange.
I use the code below for saving:
Sub Realisatie_Opslaan()
Dim productielijnMW As Integer
Dim PloegNr As Integer
Dim Datum As String
Formnaam = Screen.ActiveForm.Name
productielijnMW = DLookup("productielijn", "TblAlgemeen", "[GebruikerNr] = 1")
PloegNr = Forms(Formnaam)!txtPloegNr
Datum = Forms(Formnaam)!txtDatum
'Productie van goede blokken'
Set db = CurrentDb
Set rst = db.OpenRecordset("Select Productielijn, Lijngedeelte, Type, Dienst, Datum, Aantal from TblProductie where productielijn = " & productielijnMW & " and format(Datum, 'dd-mm-yyyy') = '" & Datum & "' and dienst = " & PloegNr & "", dbOpenDynaset)
'Realisatie_1_1
If Forms(Formnaam)!txtReal_1_1.Enabled = True Then
If Forms(Formnaam)!txtReal_1_1 <> "" Then
rst.AddNew
rst!Productielijn = productielijnMW
rst!Lijngedeelte = Forms(Formnaam)!txt_lbl_1
rst!Type = Forms(Formnaam)!txt_lbl_1_1
rst!Dienst = PloegNr
rst!Datum = Datum
rst!Aantal = Forms(Formnaam)!txtReal_1_1
rst.Update
End If
End If
End sub
Because it happens randomly i'm not able to find a clear answer on the problem. Is it possible that it happens when the db object and the recordset are not closes as following:
set rst = nothing
set db = nothing
I can't say this fixes it because of the randomness of the problem appearing.
EDIT: I've waited a while to see if I could get an error. The following error appeared:
"ODBC – delete on a linked table failed"
ElseIf rst.RecordCount > 0 Then
'Verwijder de huidige productie getallen
Do While Not rst.EOF
rst.Delete
rst.MoveNext
Loop
the error is on the rst.delete statement. Don't know why this won't work suddenly
Thanks in advance,