472,779 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

Could not update; currently locked by another session on this machine.

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
May 25 '06 #1
1 8360
All,
after days of research, the only solution I could find was to close the
main form.

Below is how I did it!!!!

Public Sub cmd_UpdateMemo_Click()
On Error GoTo UpdateError

Dim SubName As String
Dim ControlName As String
Dim IR_No As String
Dim strUser As String
ControlName = Mid(Me.OpenArgs, 1, InStr(Me.OpenArgs, ";") - 1)
IR_No = Mid(Me.OpenArgs, InStr(Me.OpenArgs, ";") + 1)
SubName = "Private Sub cmd_UpdateMemo_Click()"
strUser = Displayname(Forms!frm_UserLogin!txt_UserID) 'Use DisplayName
function to get Current users Full Name

'If no update is required, close the form and drop changes
If MsgBox("Are you sure?", vbYesNo + vbQuestion, "Confirm Update") = vbNo
Then
DoCmd.Close acForm, "frm_Memo_Update"
Exit Sub
End If

'An update is required
'Release the unbound locks on the form

Forms!frm_IR_Entry!txt_LockedIR = Null
Forms!frm_IR_Entry!chk_HasLock = False

'Then close the form
DoCmd.Close acForm, "frm_IR_Entry", acSaveYes
'Set the recordset ready for update
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 = ControlName
strCriteria = "[IR_Number] = '" & IR_No & " '" '**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

'Update complete, re-open the form at the same record and then set the
unbound locks again
DoCmd.OpenForm "frm_IR_Entry", acNormal, , "IR_NUmber = '" & IR_No & "'"
Forms!frm_IR_Entry!txt_LockedIR = IR_No
Forms!frm_IR_Entry!chk_HasLock = True

UpdateExit:
Exit Sub

UpdateError:
LogLine (SubName & " - " & Err.Description)
'MsgBox Err.Description
Resume UpdateExit

End Sub


"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:lg************@newsfe6-win.ntli.net...
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

May 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: akiddo | last post by:
Working in Access 2000: I have found several posts for this error message in various forums across the internet, but no answers. Can anyone explain why this happens? It only seems to occur...
0
by: Andrew Donnelly | last post by:
I am trying to update a memo field in a table from a form that I have created. The form is unbound, and once the user makes their changes, they have to click the continue button. Once the button...
3
by: David W. Fenton | last post by:
A very old app of mine that's been in production use, and largely unchanged since about 1998 has started recently throwing error 3188 (can't update, locked by another session on this machine) when...
1
by: StephenWeiss | last post by:
Have a vb6 program that was connecting to an Access 97 database. We have converted the database to Access 2003 and changed the provider to use Jet 4.0 Now we are running into Could not update;...
2
by: CWogksch | last post by:
Hello, Everyone... My name is Chris Wogksch. I have a point of sale application developed in VB6 using MS Access 2003 as the database. I've been running versions of this app for over eight...
0
by: Access Programming only with macros, no code | last post by:
ERROR MESSAGE: Could not update; currently locked by another session on this machine. BACKGROUND I have the following objects: Table1 - HO (which has about 51,000+ records) Table2 -...
2
by: mike2020 | last post by:
I am using VB 6, ADO and Access in my Apps. I have one table which has a Memo field, and while saving recordset (rs.Update), at that point I am receiving the following error "Could not save;...
6
by: stuart | last post by:
I have 2 users who ran into a problem with a data entry program (written in Access 2003). One user was keying into one of the forms when she got the message "ACCESS Error Number: 3218 Could not...
11
by: fniles | last post by:
One of our application uses VB6 and Access97 database. Another application uses VB.NET 2005. This morning for about 15 seconds when the application tries to read either a query or a table from the...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.