Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write Conflict 1

Status
Not open for further replies.

lars7

Technical User
Aug 16, 2005
817
GB
Hi,
I am trying to update some fields in a table from a check box but i'm getting a "write conflict message" with 2 seperate bits of code. I have tried them on-click and after-update.

Dim strSQL1 As String


If (Me.Check1) Then

strSQL1 = "UPDATE tblKSF SET tblKSF.KSFGroup ='" & [Forms]![formmain]![FormSubKSF]![Group] & "', tblKSF.KSFDate = Date() " & _
"WHERE tblKSF.[Pay Number] ='" & [Forms]![formmain]![Text6] & "'"

CurrentDb.Execute strSQL1, dbFailOnError


and

If (Me.Check1) Then
'CurrentDb.Execute "UPDATE tblKSF SET tblKSF.KSFDate = Date() WHERE tblKSF.[Pay Number] ='" & Me![Pay Number] & "'"
CurrentDb.Execute "UPDATE tblKSF SET tblKSF.KSFGroup ='" & Me![Group] & "' WHERE tblKSF.[Pay Number] ='" & Me![Pay Number] & "'"
Else
CurrentDb.Execute "UPDATE tblKSF SET tblKSF.KSFDate = null WHERE tblKSF.[Pay Number] ='" & Me![Pay Number] & "'"
CurrentDb.Execute "UPDATE tblKSF SET tblKSF.KSFGroup = null WHERE tblKSF.[Pay Number] ='" & Me![Pay Number] & "'"
End If

End Sub

the code is updating the fields with the correct information but it's when I try to move away that the message comes.

Can anyone help me with this.
 
Hi there,
I moved the code to lost focus and it looks ok, so far. :->
 
False Alarm,the codes not firing from their. Any ideas anyone.
 
Are you trying to update the current record ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH,
Yes I want to tick the box and a group and Date() to go to fields in the same record but if the box is unticked I would like those 2 fields to go blank, I seem to be making hard work of this. :)
 
So, why not simply play with the bound controls ?
In the AfterUpdate event procedure of Check1:
If Me!Check1 Then
Me!KSFDate = Date
Else
Me!KSFDate = Null
Me!KSFGroup = Null
End If

What am I missing ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH,
I've never though of doing it that way, I always update by referencing the table but not anymore. Thanks as always:

Private Sub Check1_AfterUpdate()

If Me!Check1 Then
Me!KSFDate = Date
Me!KSFGroup = Forms!formmain!Group
Else
Me!KSFDate = Null
Me!KSFGroup = Null
End If

End Sub

Check1 is on a subform.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top