T
TESA0_4
Hi,
I have a form open that is using tblRiskAssess as its Record Source. On the
form is a command button that allows a user to initiate an 'archiving
process' that is intended to change the status of another record on
tblRiskAssess to 'Archived'. The code that is intended to complete this
process is as follows:
Dim MyDb2 As DAO.Database, MyRec2 As DAO.Recordset
Set MyDb2 = CurrentDb
Set MyRec2 = MyDb2.OpenRecordset("select [RAStatus], " & _
"[ApproveUse], [ArchivedDte], [ArchivedBy] " & _
"from tblRiskAssess where [RAIDAuto] = " & ArchiveRAIDAuto)
While Not MyRec2.EOF
MyRec2.Edit
MyRec2!RAStatus = "ARCHIVED"
MyRec2!ArchivedDte = Date
MyRec2!ArchivedBy = CurrentUser()
MyRec2.Update
MyRec2.MoveNext
Wend
When the code runs I get error 3188 Cannot Open Recordset - Locked by
another session.
I assume the error message appears because I am trying to update
tblRiskAssess at the same time as the open form is displaying another record
from tblRiskAssess.
If my assumption about the cause of the error message is wrong please
advise. If my assumption is correct, what do I need to do to enable the other
record to be updated while the form is open?
Thanks in anticipation of any guidance.
I have a form open that is using tblRiskAssess as its Record Source. On the
form is a command button that allows a user to initiate an 'archiving
process' that is intended to change the status of another record on
tblRiskAssess to 'Archived'. The code that is intended to complete this
process is as follows:
Dim MyDb2 As DAO.Database, MyRec2 As DAO.Recordset
Set MyDb2 = CurrentDb
Set MyRec2 = MyDb2.OpenRecordset("select [RAStatus], " & _
"[ApproveUse], [ArchivedDte], [ArchivedBy] " & _
"from tblRiskAssess where [RAIDAuto] = " & ArchiveRAIDAuto)
While Not MyRec2.EOF
MyRec2.Edit
MyRec2!RAStatus = "ARCHIVED"
MyRec2!ArchivedDte = Date
MyRec2!ArchivedBy = CurrentUser()
MyRec2.Update
MyRec2.MoveNext
Wend
When the code runs I get error 3188 Cannot Open Recordset - Locked by
another session.
I assume the error message appears because I am trying to update
tblRiskAssess at the same time as the open form is displaying another record
from tblRiskAssess.
If my assumption about the cause of the error message is wrong please
advise. If my assumption is correct, what do I need to do to enable the other
record to be updated while the form is open?
Thanks in anticipation of any guidance.