Unable to Save Due to Record Locking (by Current Machine) - ms-access

Updated***
To quickly summarize what I said before which was lengthy and probably too roundabout confusing...
My issue was I have a main form interface with 2 subforms that does the following:
the First one is always shown for current daily event task(s) based on a label control with current date or any given dates via the prev/next toggle buttons as criteria.
The second one is part of the main subform that will be called based on the selection from the main navigation controls. This subform shows all the event tasks that are created in the database.
Both use saved query select statements with a snapshot and no record lock as recordsource in a continuous form. The table source is linked via split database in the same shared network drive and the table itself contains only 8 fields:
ID (12 chars randomly generated with specific sequence via VBA with no duplicate allowed)
Event Name (Text)
Event Desc (Long Text/Memo)
Occurrence (Text)
Start Date (Date)
Selected Day (Text)
Allow Weekend (Text)
Active (Boolean)
To edit a selected record, it will be called and populated onto a popup unbound model form via VBA. Here everything works fine as for records with fewer chars found in the Event Desc field. However, for records with a large number of chars (so far those that I noticed with issues were the ones with >4000 chars). I can call and display them fine to the detail view form (unbound) but when making edits, by the time it gets to the updating field for Event Desc, it would generate the record locking error by the same user (me) for those with large text size.
After several trials and errors, I noticed it has to do with the displayed continuous subforms that I have presenting. I noticed that the form for them were originally set as dynaset to which I tried to switch over to snapshot and it was a hit and miss (mostly miss). I don't know how much of this setting was an issue to the record updating as I had no problem saving records with smaller character counts.
Finally, I decided to before saving the record, I went and remove the recordsource for both of the continuous forms to empty ("") then save then reassign the query (saved or direct doesn't matter) and it worked without errors after. I personally don't like doing it this way as it makes the continuous forms update look ugly and not smooth (see the #Name?) in the assigned controls due to unrecognized control source since the recordsource is now empty. However, this was the best way that I could think up at the moment.
I even tried using a bounded form for editing the record instead of the unbound form and the same error outcome, but that time it gave a different record locking error# but pretty much for the same reason.
I'm sure this issue is not related to how my VBA code was written nor the queries used in the continuous forms. It's most likely the form settings themselves or just some limitation of Access?

Related

Write conflict; Need an event that triggers with popup form activation in MS Access

I have frmMain that has a number of subforms that are contained in several tabs on tab control on frmMain. I have subForm3 on one of the tabs of frmMain. subForm3 has a textbox control called tbxNote. tbxNote requires one user to make changes to the note based on feedback from a supervisor that is shown in a separate, non-modal popup form called frmFloater that appears above frmMain so that the supervisor's note shown in the non-modal form can be seen while tbxNote in frmMain.subForm3 is being editted.
Now, both frmMain and frmFloater can change the data in the same table. I understand that this is what is causing the write conflict error I am receiving.
So, I want to be able to trigger a save of the data in subForm3 when the user exits tbxNote, for example, the user exits by clicking frmFloater or a control in frmFloater. And, I want to trigger a save of the data in frmFloater when I exit frmFloater or click a control in frmMain.
The problem I am running into is that I cannot find an event that triggers when I leave frmMain or when I enter frmFloater; nor can I find an event when I leave frmFloater or when I enter frmMain.
I have tried the following events for frmMain (and also in frmFloater), none of which trigger when the user leaves frmMain (e.g., by clicking into frmFloater) nor do they trigger when the user leaves frmFloater (e.g., by clicking into frmMain):
On Deactivate
On Activate
On Current
On Click
On Got Focus
On Lost Focus
How can I detect switching to a different form so that I can save out the data in the first form before handing control over to the 2nd form?
If there are 2 forms showing 1 record, you will always run into problems. I would look at separating the record into 2 tables and creating a relationship between the tables to prevent corruptions of records. For example:
Table 1 will hold the main information of the record being viewed
Table 2 will hold the supervisor notes
The relationship between the tables will be either a 1 to 1 (if you want a note to be a single record and all updates the current note) or a 1 to many (if you want multiple records with multiple notes
be sure to check "enforce referential integrity", "Cascade Updating", and "Cascade Deleting". Otherwise you will have orphan records.
To answer your question, it cannot be done with the current setup. If employee A is editing the record on frmMain and a supervisor opens frmFloater and begins adding notes. You just corrupted the record... Reason being is, you cannot have the front end the employee has save the record the front end the supervisor has. only their machine can save the record the specific person has accessed. make sense?
There is another solution, and that would be making frmFloater an unbound form. There is quite a bit of programming involved to accomplish this, but once I made all my forms in my Access Databases unbound and all the controls unbound, I never had a corrupted record incident again. But this requires a button building the query before opening the form, open the form, then take the values from the query and place the values in the corresponding textbox on your form, then close the query. This will give you a snapshot view of the record on the table without being bound to it. Your button/afterupdate event can then run an update query on the record without locking it.
Let me know if this helped or if this did not make sense. If it didn't make sense, I'll try to explain a little better.

Updateable subform adds "#http://#" to end of hyperlink field when edited

I have a form with a subform that lists current material information being entered on the main form, like a log/history view.
On the subform there is a field that specifies which skid the product was assigned. I made this field a hyperlink so that I could use the OnClick event to launch a report and be able to extract row information needed to generate the proper summary.
That works great, and I thought it was finished until I attempted to edit the skid number from within the subform.
Allowing edits in the subform is a project requirement. Editing the skid number in the hyperlinked field breaks my code. Access automatically appends #http://# to the end of whatever value I enter into the cell and updates the table with this string. That row then gets omitted from the report because I'm keying off of the skid numbers. By design, this hyperlink has no path or address, I just use it to determine which row is being clicked.
How can I prevent Access from appending the #http://# while keeping the "Is Hyperlink" property to Yes? Is there another property to set this behavior or should I use the AfterUpdate event to undo the addition, which just seems like a waste of resources?
I am running Access 2010.
There is a long and very thorough article here that I will not copy ;) It elaborately states why its a bad idea to even use the hyperlink-field and what to do to get the same result you need without a hyperlink-field.
Basically, the main point of the hyperlink-field is all that behind the scenes shenanigans you cannot do anything about - and thats not what you want as a programmer.
The Hyperlink-field internally consists of three parts: A Text-part, a Link-Part and a Tooltip-Part. And although you can access them separately, access always tries to create a link.
You can try to format the data you have in the internally used format (DisplayText#Address#SubAddress) but I think that is not what you need...
So I think you best take Philipps advice and change your field-type.

Access Linked Tables, how to force relational values

Hopefully the image above makes it thru. So the way this works is that a user uses a form to enter the values on the Vuln_Remediation_Planning table. After all vulnerabilities associated with a patchID and existing OS have been entered, he moves to the next form where he is suppose to mitigate the risk associated with the vulnerabilities, and you can have multiple mitigating measures which is why the table is separate.
My question:
Right now when using the compensation form, the user has to select each patchID, OS, and vulnerability ID for each mitigating measure they select... this is cumbersome and error prone. Recall the first form only operates on the planning table, the second form operates on the compensation table.. but they are related so I feel the user would want to use a single drop down to select the top the primary keys, already assign in the previous table.
I was going to ask how to handle this, but I may have solved my own problem... 3 column combo box right, with the row source coming from the Remediation planning.... lol what do you think, any other ideas?
I figured it out. On the compensation table I just created a continuous form, and moved the OS and patchID fields to the header. When opening the form normally, it looks funny because the header values change when records are selected (as would be expected if they were all on the same row). Then from the remediation planning form, I have a button to open the compensating measures form that filters it so only the patchID/OS of the parent for is shown. Additionally, in the open event of the compensating measures form, I set the default values of PATCHID/OS using open args (in case no records are there yet or the user adds new records... otherwise it opens blank when there are no records.

MS Access - Form tries to create new record on open and record jumps about a continuous form

So I have two issues with my database, which I think are linked together.
Firstly if tblDeliveries is empty and frmMainView is opened it comes up with "You must enter a value in the 'tblDeliveries.deliverySlot' field" but the form shouldn't be trying to create a record and I can't see any reason why it would. Opening frmDailyView (which is a subform of frmMainView) doesn't show this behaviour but it is the one with the continuous form on...
Secondly if tblDeliveries has one (or more) rows the first row of the table will jump about... For example in frmMainView if the date of the first record is set to 23/01/2015 and you navigate to the 24/01/2015 and click anywhere on the subform and then press F5 to refresh the record will have jumped to that date, the date even changes in tblDeliveries.
I have no idea why it's doing it, I even removed all of the VBA code for the form to stop it, but it happens anyway.
If anyone has come across anything like this before, please let me know how you fixed it, or any suggestions would be very welcome. Thanks!
EDIT: If you download the database, add your computer login name to tblUsers. Also the date is UK formatted, so might need tweaking to work with US dates.
The offending database (1.5MB)
Taking a look at your database, several issues are occurring.
You first issue can be resolved by going into the Design View of the table tblDeliveries, select the deliverySlot field and change Required (in bottom panel) from Yes to No.
Your second issue is multi-faceted with many issues but a critical problem is that the parent-child link field, deliveryDate, between the main form and subform is missing in the recordsource of the sub form and the field's table origin is not in the query's join statements. For me, I can't even update anything in subform (all boxes are grayed out).
Essentially, you are trying to normalize Delivery Dates and Delivery Times (one-to-many) but the left join query (qryDeliveryIncBlanks) setup is not aligned to this effect. You user login also does not integrate smoothly into frmMainView. My ultimate advice is revamp your database design relational model then use forms as the visual representation of those related tables.
I am not re-iterating the points of #Parfait.
Access Forms have a property DataEntry. If it is set to Yes (or True in VBA), then the form will open itself pointing to a new empty data record. Set this property to No (False in VBA).
If you want to give the user the possibility to manually enter a new record, set the property AllowAdditions to Yes and to No otherwise. Yes displays an empty record marked with a star * and the end of the data sheet or continuous form.
I've resolved the issue, thanks to some of the comments I realised I could just give the deliverySlot field a default value with a number outside of the range it would look for, I set it to 99, but it only looks for 1-20. The date still jumps around but since it's not in the range of the query it's hidden. It's resolved both issues.

How Do I Make a Subform Controlled by Report (Which is Controlled by a Query) Update After Records Are Added?

I recently took a duty position that requires me to track our administrative actions. Previously, the office had tracked them on an Excel spreadsheet, and the historical data was corrupted/missing. So I have built a database in Access 2010. I designed the database to display a main form that provides an overview of each action, but decided to require most of the data to be added or updated on specific data entry forms. My question relates to two subforms on the main form that I cannot get to update after data is entered into the tables. Here are specifics:
1) The main form is the case detail form, and each case has a unique case ID number that links most of the forms and tables.
2) The Case Detail Form has two subforms. One displays the names of the people involved in the case (this is the Subject Subform). The other displays the case history entries (this is the Case History Subform).
3) Both of the subforms are supposed to work the same way. Each is populated by a report which displays the information in its corresponding Subform. In turn, the reports underlying each Subform are based on a query that selects the records to display based in the case number.
4) New data for the subforms cannot be entered on the Case Details Form. Instead, the user can press a command button which launches a separate form that allows the user to enter either subject details or to enter a case history update. Once the user enters the data, he or she clicks A Save Record button, which saves the record and closes the form window. Everything seems to work fine up to this point.
5) However, I've now been working on this project for two weeks (as time permits), and I am still not able to make the two subforms update automatically. If it's a new case record, the user can make the Subforms update by using the navigation arrows to leave the main Case Details Form and then returning to it. If it's an established case record, a refresh button that I have added to the main Case Details form will cause the two subforms to update.
As I've tried to make this work, I've tried a number of approaches that I've found on various boards. Right now, I have:
A) The Subject data entry form has a Me.Requery statement in After Insert Event Procedure
B) The Subject data entry form has a SaveRecord and a CloseWindow command that are executed when the Save Record Button On Click event is triggered.
C) The main Case Detail Form has a executes a Me.Case_Subjects.Form.Requery when the GotFocus Event Procedure is executed.
I apologize for the lengthy question and explanation. I'm an Army officer and a little out of my depth with this. I would greatly appreciate any help anyone might be able to offer.
Best regards!
I'm not sure having understood everything but I try to give you some suggestions about what to try.
If I'm not wrong both form and subforms have the case ID as field so when you created the report you should have put them in "link" by the wizard (you can set it manually after but it's a bit more tricky).
Did you do this? This makes the form / subforms update when you navigate them.
Please note that there must be a relation between the underlaying tables to guarantee that the reports / forms moves together!
This applies to the query too, just remember to include the ID field int the queries.
If you don't want to see the ID (in case you use an autonumbering id) you can set it Not Visible.
In case you don't want to link the two tables with a relation there is another solution but it's a bit more tricky and, if it's not your case, I don't want to make confusion.
Let me know if you solved.
Bye
Firstly, the line Me.Requery should be on the After Update event, not the After Insert event. Secondly, you will then need to change Me.Requery to Me.[insertsubformname].Requery.
As the user above said, you will need to ensure that you have created your database relationships properly, however if you used the Insert Subform, it should've asked you what you wish to use as your link between the forms.