Write conflict

M

Max

I have the following code in the after update field of a subform that
prompts the user to change all dates if more than one record is present.

The code runs and changes the records, but I get a write conflict when I try
to close the main form when more than one record is present in the subform.
It appears that the Update is not saving the record.

Any suggestions?

Thanks in advance,
Max

'If date changed prompt to set all dates to the same for existing procedures
Dim rs As Recordset, Response As Integer, Msg As String, ProcDate As Date

ProcDate = Me.ProcedureDate

Set rs = Me.RecordsetClone
rs.MoveLast
If rs.RecordCount <= 1 Then Exit Sub

Msg = "Do you want to set all procedures to this date?"
Response = MsgBox(Msg, vbQuestion + vbYesNo + vbDefaultButton1, "Date
changes")
If Response = vbNo Then Exit Sub

With rs
.MoveFirst
Do Until .EOF
.Edit
![ProcedureDate] = ProcDate
.Update
.MoveNext
Loop
End With
rs.Close
 
G

Guest

Max
No-one's given you an answer. I am not sure I know the answer but have you
tried a requery on the subform or form after the update?
Me.requery
Good luck
Stephen
 
M

Max

Thanks for the input.
I tried this, but this line of code now triggers the same error message
before I try to exit the form.

Max


Stephen English said:
Max
No-one's given you an answer. I am not sure I know the answer but have you
tried a requery on the subform or form after the update?
Me.requery
Good luck
Stephen

Max said:
I have the following code in the after update field of a subform that
prompts the user to change all dates if more than one record is present.

The code runs and changes the records, but I get a write conflict when I try
to close the main form when more than one record is present in the subform.
It appears that the Update is not saving the record.

Any suggestions?

Thanks in advance,
Max

'If date changed prompt to set all dates to the same for existing procedures
Dim rs As Recordset, Response As Integer, Msg As String, ProcDate As Date

ProcDate = Me.ProcedureDate

Set rs = Me.RecordsetClone
rs.MoveLast
If rs.RecordCount <= 1 Then Exit Sub

Msg = "Do you want to set all procedures to this date?"
Response = MsgBox(Msg, vbQuestion + vbYesNo + vbDefaultButton1, "Date
changes")
If Response = vbNo Then Exit Sub

With rs
.MoveFirst
Do Until .EOF
.Edit
![ProcedureDate] = ProcDate
.Update
.MoveNext
Loop
End With
rs.Close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top