Write conflict

Peetee

New member
Local time
Today, 00:43
Joined
Aug 21, 2008
Messages
5
I have a form (frmClient) which includes a locked textbox txtLastModifedBy which is bound to tblClient.LastModifiedBy.

When other controls on the form are updated, the form's BeforeUpdate event triggers some code which includes the line

DoCmd.RunSQL "UPDATE tblClient SET tblClient.LastModifiedBy = 'user' WHERE tblClient.ClientID= 10;"

I've used ClientID=10 to make sure there's no problem with how I'm defining the current record (previously I had ClientID= {value of ClientID textbox}).

The error message that appears is Write Conflict: "This record has been changed by another user since you started editing it. If you save the record you will overwrite the changes the other user made." 3 options are presented: Save record; Copy to clipboard; Drop changes.

What I think is happening is that the textbox txtLastModifedBy is bound, so it is preventing changes from the code. I can't expect my users to use the database like this. I've looked through previous posts about write conflicts but couldn't see anything that would help in this case. Any ideas?
:confused:
 
There's no need to run SQL if the control is already bound to the table/field:

Me.txtLastModifedBy = "user"

Though I think it will need to be in the after update event.
 
Thanks for this Paul - this has worked, and was a much simpler solution.:)
Incidentally, the code had to be attached to the Before Update event. Attaching the code to the After Update event made it run in a loop of update form (manually)>run code>update form (programatically)>run code>update form (programatically)>...
 

Users who are viewing this thread

Back
Top Bottom