Why do I get this error? (1 Viewer)

FISHiEE

Fish obsessive
Local time
Today, 18:06
Joined
Nov 12, 2004
Messages
86
Hi,

I have the following section of code:

rst2.MoveFirst
Do While Not rst2.EOF
If rst2![Door_Part_Number] = Forms![Parts database for editting records - duplicate only]![Door Part Number] Then
If rst2![Extra_Code] = "NEW" Then
With rst2
.Edit
![Extra_Code] = str_ExtraCode
.Update
End With
End If
End If
rst2.MoveNext
Loop

When this code is run, at the edit stage I get the following error:

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

I can't see that I have rst2 - the recordset of tbl_Doors&Extras opened anywhere else and not closed it.

If anyone has any ideas on why this error is occuring and how to solve it I would be most grateful.

I don't have rst1 also declared as the recordset of tbl_Doors&Extras for example.

Thanks in advance

John
 

Bat17

Registered User.
Local time
Today, 18:06
Joined
Sep 24, 2004
Messages
1,687
is rst2 using the same table as Forms![Parts database for editting records - duplicate only] ?

Peter
 

FISHiEE

Fish obsessive
Local time
Today, 18:06
Joined
Nov 12, 2004
Messages
86
Thanks Peter.

I have actually just worked out that it's because the code is modifying the field I am in of that particular record. and it is being run by the after update event. If I run it on the lose focus event it is fine.

I would really like to be able to have the code run before the user switches to another control.

What happens is the user selects from the combobox the option of "NEW" and it then opens a new form where a new extra is created. The code then puts that extra where "NEW" has been selected.

Perhaps this can be run from a different event. Just need to work out which one!
 

Users who are viewing this thread

Top Bottom