Microsoft
Software
Hardware
Network
Question : After update subform, then update the main form field
Hi Guys
I need to update the main form any time that i do a change on the main form or in the subform, so what i did is in the main form after update event i put this code
Private Sub Form_AfterUpdate()
Dim strSQL As String
DoCmd.SetWarnings False
strSQL = "UPDATE TreatmentDetails SET TreatmentDetails.LastUpdat
eDateTime = Now(), TreatmentDetails.LastUpdat
edUserID = DLookup('[user_id]', 'qryUserSecurity', '[user_name] = LAS_GetUserName()') WHERE (TreatmentDetails.Treatmen
tDetailsID
= [Forms]![Switchboard]![sub
frmWindow]
.[Form]![T
reatmentDe
tails].[Fo
rm].[Treat
mentDetail
sID]);"
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End Sub
Now in the subform i did the same, i add the same code, because it is running an update query, it is working ; when i change the subform and then i click anywhere in the form it does not give me any message, but if i click in a list box, that is listing all the records it gives me this message
"The data has been change. Another user edited the record and saved the changes before you attempted to save your changes.
Re-edit the record"
in the list box i have this On click event
Private Sub lstTreatment_Click()
'Move to the record selected in the control
DoCmd.SetWarnings False
Me.RecordsetClone.FindFirs
t "[TreatmentDetailsID] = " & Me![lstTreatment]
Me.Bookmark = Me.RecordsetClone.Bookmark
'******* Code End *********
DoCmd.SetWarnings True
End Sub
what can i do to avoid this message
best regards
Answer : After update subform, then update the main form field
Requery the list box first somewhere after you updated it at the end of your docmd.setwarnings true
lstTreatment.requery
Random Solutions
Disable 'create profile' enquiry in Windows 7
Display No Rows or No Data Found Message for the Matrix in SSRS
Page life expectancy
MS Word conversion to Adobe
Regional settings GREEK , decimal separator "," sql server 2000, But does not update a textbox tha binds to a float field,C# framework 2.0
SoapException when passing a class to web service
Can Access 2003 and 2007 coexist in peace on the same machine?
Drawing and Scolling in Windows C# - ClientRectangle? Paint?
Small Business Server 2008 - TASK Scheduler Errors
Access Query Error: specified expression as part of an aggregate function