Solved

After update subform, then update the main form field

Posted on 2009-05-11
1
879 Views
Last Modified: 2013-12-20
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.LastUpdateDateTime = Now(), TreatmentDetails.LastUpdatedUserID = DLookup('[user_id]', 'qryUserSecurity', '[user_name] = LAS_GetUserName()') WHERE (TreatmentDetails.TreatmentDetailsID = [Forms]![Switchboard]![subfrmWindow].[Form]![TreatmentDetails].[Form].[TreatmentDetailsID]);"
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.FindFirst "[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
0
Comment
Question by:titorober23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
lucas911 earned 250 total points
ID: 24355831
Requery the list box first somewhere after you updated it at the end of your docmd.setwarnings true

lstTreatment.requery
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question