G
Guest
I am trying to modify values of the currently selected record of a form in VB
Code. The following gets called when the check box is clicked on a treeview
on the form:
rs.Edit
If (complete) Then
rs("LastStatus") = rs("Status")
rs("Status") = CStatus
Else
rs("Status") = rs("LastStatus")
rs("LastStatus") = CStatus
End If
rs.Update
I get the error message, "Run-time error '31'97': The Microsoft Jet database
engine stopped the provess because you and another user are attempting to
change the same data at the same time." on the rs.Update.
I thought that rs.Update dbUpdateCurrentRecord might solve the problem, but
I get an "Invalid Argument" error on that call.
I have tried setting rs = Me.recordset and Me.recordsetclone; neither seem
to work. I have also tried calling me.refresh first and setting me.dirty =
false all to no avail.
I am assuming that since the mouse_click event code sets the current record
based on which node was clicked in the treeview, that access is using
something akin to "Me.recordset.edit" as soon as it changes to the current
record. This "locks" the current record and I am not allowed to concurrently
edit the data.
Unfortunately, I cannot put code in the "current" event procedure to
disallow edits since I have no way of knowing if the node has been "checked"
or just simply clicked.
I realize that I can access the fields of the recordset directly in VB (i.e.
"LastStatus = Status"). This would be fine in most cases, but there are
others in which I am forced to iterate over the records in the recordset and
this may include the "current record" that is open on the form. Perhaps I
could just check for the condition that the current record in the recordset
is the same as the one in the form, but I would really like to avoid this. I
have a hard time believing and can't force access to temporarily relinquish
its lock on the current record.
So, my question is, how can I programmtically edit the values of fields in
the current record of the form using a recordset?
Code. The following gets called when the check box is clicked on a treeview
on the form:
rs.Edit
If (complete) Then
rs("LastStatus") = rs("Status")
rs("Status") = CStatus
Else
rs("Status") = rs("LastStatus")
rs("LastStatus") = CStatus
End If
rs.Update
I get the error message, "Run-time error '31'97': The Microsoft Jet database
engine stopped the provess because you and another user are attempting to
change the same data at the same time." on the rs.Update.
I thought that rs.Update dbUpdateCurrentRecord might solve the problem, but
I get an "Invalid Argument" error on that call.
I have tried setting rs = Me.recordset and Me.recordsetclone; neither seem
to work. I have also tried calling me.refresh first and setting me.dirty =
false all to no avail.
I am assuming that since the mouse_click event code sets the current record
based on which node was clicked in the treeview, that access is using
something akin to "Me.recordset.edit" as soon as it changes to the current
record. This "locks" the current record and I am not allowed to concurrently
edit the data.
Unfortunately, I cannot put code in the "current" event procedure to
disallow edits since I have no way of knowing if the node has been "checked"
or just simply clicked.
I realize that I can access the fields of the recordset directly in VB (i.e.
"LastStatus = Status"). This would be fine in most cases, but there are
others in which I am forced to iterate over the records in the recordset and
this may include the "current record" that is open on the form. Perhaps I
could just check for the condition that the current record in the recordset
is the same as the one in the form, but I would really like to avoid this. I
have a hard time believing and can't force access to temporarily relinquish
its lock on the current record.
So, my question is, how can I programmtically edit the values of fields in
the current record of the form using a recordset?