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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record-locking 2

Status
Not open for further replies.

jgarnick

Programmer
Feb 16, 2000
189
US
I realize that this may be too confusing to be answered here, but here goes anyways....<br><br>I have a form with a subform. The form is based on table A and the subform is based on table B.&nbsp;&nbsp;Table A and B are related by an id field.&nbsp;&nbsp;The relationship is a one-to-many.<br><br>In the subform, if a user enters a certain code in a field, I have another form popup that displays Table C data for the user to confirm, before hitting an update button.&nbsp;&nbsp;The update button runs an update query that updates table C with the displayed Tables A and B data.&nbsp;&nbsp;Table C is not related to A or B.<br><br>So far I believe everything works.&nbsp;&nbsp;It is when the popup form closes and I am back in my original form/subform. From there the user clicks on a button that is supposed to add a new record to table A.&nbsp;&nbsp;I get a write conflict error asking you to save record, copy to clipboard or drop changes.&nbsp;&nbsp;It appears that Access thinks another user has opened this record and I'm not sure why it thinks that or how to get around that--it would be the same user. <br><br>Any help would be appreciated! <p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You would not *believe* what I went through recently with this same problem.&nbsp;&nbsp;The solution I came up with was actually pretty simple, and it works well so far as I've been using it.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;All I do is, before any changes are made I close the first form.&nbsp;&nbsp;In your example this would be the form displaying data from tables A and B.&nbsp;&nbsp;Pass any information you need in order to update the records to the new form though first of course.&nbsp;&nbsp;This can be done simply by making sure the &quot;docmd.openform&quot; statement for the second form is placed ahead of the &quot;docmd.close&quot; statement to close the first form.&nbsp;&nbsp;Once the form is closed, the user can confirm the update without worry of conflicting with any other open forms.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;After this you must just add some additional code to your &quot;Confirm&quot; button to ensure that the first form is reopened at it's original place, making it seem almost as if it were minimized while they took action elsewhere.&nbsp;&nbsp;Like I said, this has worked well for me thus far, but I would imagine that in certain circumstances it would become extremely difficult if not impossible all together.&nbsp;&nbsp;I hope this helps, and good luck!<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
Here is a quick solution that usually works for me.<br><br>Use the SaveRecord command before closing the update form that is based on Table C.&nbsp;&nbsp;Here is the code.<br><br>DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70<br><br>Chances are you have a button to close the form.&nbsp;&nbsp;insert this line in that button, before the acutal close command.&nbsp;&nbsp;It will force the save.&nbsp;&nbsp;You can also use this line to save the record just prior to opening the update form too.<br><br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thanks 3rdRail, that was very helpful to me as well.&nbsp;&nbsp;One thing I noticed while looking into that was that it seems &quot;DoCmd.RunCommand acCmdSaveRecord&quot; works as well, and it looks like that is what is now replaces the old DoCmd.DoMenuItem.&nbsp;&nbsp;I tried it with DoCmd.RunCommand and it works, thanks for the help...I would have written a lot of pointless stuff if it wasn't for your post.<br> <p>xtreme1<br><a href=mailto:rbio@excite.com>rbio@excite.com</a><br><a href= > </a><br>
 
No problem xtreme1.&nbsp;&nbsp;Thanks for the update on the command.&nbsp;&nbsp;I'm using access 97 at home and 2000 at work and I'm still learning the new commands.
 
Thanks to both of you--unfortunately neither suggestion worked-- actually xtreme1--my form and subform do&nbsp;&nbsp;not &quot;display&quot; data from table A and B, but the user actually enters the data--so I think it needs to be saved before closing the form.&nbsp;&nbsp;Also, how could I get back to right place in the first form once closed?<br><br>Thanks again-- <p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br>
 
THANKS 3rdRail - your solution worked for me! <br>The trick was WHEN to save the record_<br>&nbsp;..this solution will probably help others who have posted at &quot;write conflicts error&quot;<br><br>Thanks :)<br><br>gyma
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top