Full Version: Write Conflict Error Message
UtterAccess Forums > MicrosoftŪ Access > Access Forms
M2C
Hi
Not too sure I can explain this one well enough. I am getting a message box pop up that says I hava Write Conflict with option Save Record, Copy to Clipboard or Drop Changes. Done a bit of googling and think I need to include some TimeStamp. However done this and no joy.
My code runs fine if I just click Save Record but the other two options.
My code is (sorry cannot find the codebox):
CODE
Private Sub TopicPick_AfterUpdate()
If Me.TopicPick = -1 Then
DoCmd.SetWarnings False
'Updates the question set to -1
DoCmd.RunSQL "UPDATE TmpTopic SET TmpTopic.TopicPick = -1, TmpTopic.TmStamp = Now() WHERE (((TmpTopic.Topic_SectID)=[Forms]![FrmCampList]![FrmTmpTopic].[Form]![Topic_SectID]))"
'Adds the group of questions to the campaigns list of questions
DoCmd.RunSQL "INSERT INTO CampTop ( CampTop_CampID, CampTop_TopicID ) SELECT Int([Forms]![FrmCampList]![FrmCampSets].[Form]![CampID]) AS Expr1, TmpTopic.TopicID FROM TmpTopic WHERE (((TmpTopic.TopicPick)=True))"
DoCmd.SetWarnings True
Forms![FrmCampList]![FrmCampTop].Form.Requery
Else
DoCmd.SetWarnings False
'Updates the question set to 0 to deselect the group of questions
DoCmd.RunSQL "UPDATE TmpTopic SET TmpTopic.TopicPick = 0 WHERE (((TmpTopic.Topic_SectID)=[Forms]![FrmCampList]![FrmTmpTopic].[Form]![Topic_SectID]))"
'Flag the question set in the campaign that needs to be deleted
DoCmd.RunSQL "UPDATE (Topic INNER JOIN TmpTopic ON Topic.TopicID = TmpTopic.TopicID) INNER JOIN CampTop ON Topic.TopicID = CampTop.CampTop_TopicID SET CampTop.CampPick = -1 WHERE (((TmpTopic.TopicPick)=False) AND ((CampTop.CampTop_CampID)=[Forms]![FrmCampList]![FrmCampSets].[Form]![CampID]) AND ((TmpTopic.Topic_SectID)=[Forms]![FrmCampList]![FrmTmpTopic].[Form]![Topic_SectID]))"
'Deletes the question set if the set is unticked from the pool of questions
DoCmd.RunSQL "DELETE CampTop.CampTopID, CampTop.CampPick FROM CampTop WHERE (((CampTop.CampPick)=True))"
DoCmd.SetWarnings True
Forms![FrmCampList]![FrmCampTop].Form.Requery
End If
End Sub
Also on the OnClick event I have a save record command once I click the tick box / yes/no field.
Cheers
Chris
tina t
well, i can't really tell from the posted info, but i'm guessing that one or more of the Update queries is attempting to update the same record that is current in the open form. you're running the code from a control's AfterUpdate event, so that means that the record is probably still Dirty, despite the Save command running in the OnClick event.
You might try adding the following code to the beginning of the control's AfterUpdate event, before the rest of the code runs, as
Me.Dirty = False
and remove the Save command from the OnClick event.
hth
tina
Bob G
just a question for my own sanity. Does this actually run on its own? I would have thought that reference to the form would be in its own set of quotes.
!--c1-->
CODE
DoCmd.RunSQL "UPDATE TmpTopic SET TmpTopic.TopicPick = -1, TmpTopic.TmStamp = Now() WHERE (((TmpTopic.Topic_SectID)=[Forms]![FrmCampList]![FrmTmpTopic].[Form]![Topic_SectID]))"

I thought it should be something like this. But not sure.
CODE
DoCmd.RunSQL "UPDATE TmpTopic SET TmpTopic.TopicPick = -1, TmpTopic.TmStamp = Now() WHERE TmpTopic.Topic_SectID= " & chr(34) & [Forms]![FrmCampList]![FrmTmpTopic].[Form]![Topic_SectID] & chr(34) &"
M2C
Hi Tina
orked a treat many many thanks <
Chris
M2C
Hi Bob
the code works fine but I dont cut code from a blank as I am very much a novice when compared to you guys on this site.
The way I do this is to create the query that runs a report or form then go to SQL view and then copy the where part of the statement and paste it straight into event statement. HTMS
Cheers
Chris
cpetermann
Chris,
MFJI
Allen Browne's SQL2VBA is a tool that many developers use
to convert query SQL to VBA--takes care of my tendency to miss the correct punctuation <
You need to create a form, but he has step by step instructions! <
Personally, I created the form in its own db and then import it into dbs when developing.
HTH
M2C
Hi Cynthia
The knowledge I have of VBA / SQL is all self taught and things I have gleened from the web over 14 years. I have never had the opportunity to work with others who can teach me such things that you have just sent me and for that I thank you so much. I shall give it a go later tomorrow and hopefully get it to work.
any thanks again
Chris
tina t
you're very welcome, Chris! :)
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.