ms access run time error 3046 could not save; currently locked by another user (2 Viewers)

andy1968

Registered User.
Local time
Today, 06:41
Joined
May 9, 2018
Messages
131
I have the following code to add a record to a table after a change to a record on a form;


Code:
Private Sub Note_BeforeUpdate(Cancel As Integer)
Dim tblSubmittalLog As DAO.Recordset
Dim ddd As Date
Dim strWhat As String

ddd = Date

    If Me.NewRecord Then
    
        
        strWhat = "Added: " & Me.Note
    Else
        strWhat = "Edited the note from '" & Me.Note.OldValue & "' to '" & Me.Note & "'"
    End If
    
    
    
        Set tblSubmittalLog = CurrentDb.OpenRecordset("SELECT * From[tblSubmittalLog]")
            With tblSubmittalLog
                .AddNew
                ![ID] = Me.SerialNumber
            'Debug.Print itgID
                ![Who] = Me.Parent!Reviewer
                ![DateAction] = ddd
                ![What] = strWhat
                
                .Update
                .Close
            End With
            Set tblSubmittalLog = Nothing
Me.Parent!frmSubmittalActionLog.Form.Requery
End Sub
I get the error on the .Close line.


This just started today after months of using this procedure.


Tried closing and restarting the database, using different front ends.


The error goes away if I delete the .Close line, but I'm thinking this will cause other issues.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:41
Joined
Oct 29, 2018
Messages
21,485
Hi. Just checking, is the form being updated also bound to tblSubmittalLog?
 

andy1968

Registered User.
Local time
Today, 06:41
Joined
May 9, 2018
Messages
131
The form "frmSubmittalActionLog" is bound to tblSubmittalLog yes
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:41
Joined
Oct 29, 2018
Messages
21,485
The form "frmSubmittalActionLog" is bound to tblSubmittalLog yes
In that case, I would suggest trying to use a RecordsetClone, instead of OpenRecordset to set your tblSubmittalLog object variable. No guarantees though...
 

andy1968

Registered User.
Local time
Today, 06:41
Joined
May 9, 2018
Messages
131
That seems to work. Still a little disturbed by why it failed all of a sudden.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:41
Joined
Oct 29, 2018
Messages
21,485
That seems to work. Still a little disturbed by why it failed all of a sudden.
Hi. My guess is maybe you were just lucky. Glad to hear the new approach worked for you. Good luck with your project.
 

Users who are viewing this thread

Top Bottom