473,416 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 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 8473
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.