Hi All,
I'm having a problem with the following code. I've read quite a lot of
old posts regarding the issue but none seem to affer a solution.
The scenario is. I have a bound form which contains a couple of memo fields.
I need to keep some sort of log as to when each update of the memo field
occurs so I have locked bot the memo fields on the main form. To edit them,
the user double clicks the ememo field which then opens an unbound form.
They eneter their update and then click a command button which runs the
below code. All works fine until the memo field grws too large.
From what I gather, the size of the memo field is the deciding factor. As
soon as the update takes the character count past 2000, the below code
produces the "Could not update; currently locked by another session on this
machine." error.
Can anyone offer any solutions as I'm really stuck on this one.
TIA,
Mark
Public Sub cmd_UpdateMemo_Click()
On Error GoTo UpdateError
Dim SubName As String
SubName = "Private Sub cmd_UpdateMemo_Click()"
If MsgBox("Are you sure?", vbYesNo + vbQuestion, "Confirm Update") = vbNo
Then
DoCmd.Close acForm, "frm_Memo_Update"
Exit Sub
End If
Dim strUser As String
'Use DisplayName function to get Current users Full Name
strUser = Displayname(Forms!frm_UserLogin!txt_UserID)
Dim db As DAO.Database, RS As DAO.Recordset, StrSQL As String, strCriteria
As String, strFieldName As String
Set db = CurrentDb
StrSQL = "Select * from tbl_IRs;"
strFieldName = Me.OpenArgs
strCriteria = "[IR_Number] = '" & Forms!frm_IR_Entry!IR_Number & "'" '**This
is the Record 's unique ID **
Set RS = db.OpenRecordset(StrSQL)
With RS
.FindFirst strCriteria
.Edit
If IsNull(RS(strFieldName)) Then
RS(strFieldName) = "(" & strUser & " - " & Format(Now, "hh:nn ddd
dd-mmm-yy") & ")" & vbCrLf & Me.txt_Addition
DoCmd.Close acForm, "frm_Memo_Update"
Else
RS(strFieldName) = RS(strFieldName) & vbCrLf & vbCrLf & "(" &
strUser & " - " & Format(Now, "hh:nn ddd dd-mmm-yy") & ")" & vbCrLf &
Me.txt_Addition
DoCmd.Close acForm, "frm_Memo_Update"
End If
.Update
End With
RS.Close
Set RS = Nothing
UpdateExit:
Exit Sub
UpdateError:
LogLine (SubName & " - " & Err.Description)
Resume UpdateExit
End Sub