473,883 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Updat e"
Exit Sub
End If

Dim strUser As String

'Use DisplayName function to get Current users Full Name
strUser = Displayname(For ms!frm_UserLogi n!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_En try!IR_Number & "'" '**This
is the Record 's unique ID **

Set RS = db.OpenRecordse t(StrSQL)
With RS
.FindFirst strCriteria
.Edit
If IsNull(RS(strFi eldName)) Then
RS(strFieldName ) = "(" & strUser & " - " & Format(Now, "hh:nn ddd
dd-mmm-yy") & ")" & vbCrLf & Me.txt_Addition
DoCmd.Close acForm, "frm_Memo_Updat e"
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_Updat e"
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 8505
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.OpenAr gs, ";") - 1)
IR_No = Mid(Me.OpenArgs , InStr(Me.OpenAr gs, ";") + 1)
SubName = "Private Sub cmd_UpdateMemo_ Click()"
strUser = Displayname(For ms!frm_UserLogi n!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_Updat e"
Exit Sub
End If

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

Forms!frm_IR_En try!txt_LockedI R = Null
Forms!frm_IR_En try!chk_HasLock = False

'Then close the form
DoCmd.Close acForm, "frm_IR_Ent ry", 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.OpenRecordse t(StrSQL)
With RS
.FindFirst strCriteria
.Edit
If IsNull(RS(strFi eldName)) Then
RS(strFieldName ) = "(" & strUser & " - " & Format(Now, "hh:nn ddd
dd-mmm-yy") & ")" & vbCrLf & Me.txt_Addition
DoCmd.Close acForm, "frm_Memo_Updat e"
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_Updat e"
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_Ent ry", acNormal, , "IR_NUmber = '" & IR_No & "'"
Forms!frm_IR_En try!txt_LockedI R = IR_No
Forms!frm_IR_En try!chk_HasLock = True

UpdateExit:
Exit Sub

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

End Sub


"Mark Reed" <ma*********@nt lworld.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_Updat e"
Exit Sub
End If

Dim strUser As String

'Use DisplayName function to get Current users Full Name
strUser = Displayname(For ms!frm_UserLogi n!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_En try!IR_Number & "'" '**This
is the Record 's unique ID **

Set RS = db.OpenRecordse t(StrSQL)
With RS
.FindFirst strCriteria
.Edit
If IsNull(RS(strFi eldName)) Then
RS(strFieldName ) = "(" & strUser & " - " & Format(Now, "hh:nn ddd
dd-mmm-yy") & ")" & vbCrLf & Me.txt_Addition
DoCmd.Close acForm, "frm_Memo_Updat e"
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_Updat e"
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
1508
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 when the record contains a memo field with > 2000 characters in it. I have tried repairing, compacting, rebuilding, and copying by
0
412
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 is click then, there is some VB code that uses SQL Update to take the information on the form and update the table with the new changes. However, I am having issues with the Memo fields. I have looked at several different posts and have not been...
3
3699
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 saving edits to some memo fields. I have found a number of things: 1. it happens only with long memo fields, starting somewhere above 255 characters (though I don't know exactly where.
1
4783
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; Currently Locked when we are trying to add records to a table. Here is the code inserting records into the database. It works 95% of the time but if we are inserting a lot of data, it starts to get record locks. Public Sub Store(Conn As...
2
4739
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 years, using vb5/Access 97 and later vb6/Access 2000 and 2003, without issue. Recently, I've started selling my latest version to liquor stores in my local area. The typical installation setup is a peer-to-peer network with three workstations; a...
0
3243
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 - Contact (which has 68,000+ records)
2
3994
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; currently locked by another user." Any idea, why I am receiving this error? I will appreciate your response.
6
11340
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 update; currently locked'. About the same time, another user was keying records into a 2nd form. Even though they were on different forms, they would have added records to the same table. The 2nd user had tried to add about 28 records, the...
11
5035
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 database, in in both VB6 and VB.NET applications, I got the error "The Microsoft Jet database engine cannot find the input table or query 'myTable'. Make sure it exists and that its name is spelled correctly." Also, I got the error "The...
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11118
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10407
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9564
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7960
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5982
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4606
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.