Unfocus subform record/prevent write conflict

craigachan

Registered User.
Local time
Today, 07:24
Joined
Nov 9, 2007
Messages
285
I have a form/subform. I want to unfocus or unselect a record on the subform. Even though I can use a .setfocus to another field on the main form using the timerevent, A record in the subform still stays selected. This causes an occasional write conflict if the same record is selected by a second user on another workstation. So I would like to see if there is a way to completely unselect any record on the subform so that there is no focus on any record on the subform in order to prevent any write conflict.

I appreciate any help.
 
I think you need to pin point the write conflict problem instead of trying to mask it. If a user has a record selected there should be no write conflict. A write conflict only occurs when two users are trying to save changes made to that same record. So I would imagine that there's a problem with your code.
 
The subform is in datasheet view. Selecting a record in the subform opens another form that is unbound. Only info is loaded. Then when this form closes, it compares the data with the table in the subform and makes the necessary changes before closing the unbound form. But if that worker goes on to do other work and leaves their workstation, that record still stays selected on the subform. And then if another workstation views the same record I get the dreaded 'work conflict - save, copy to clipboard, drop changes'. The only thing that I can think of is that the record stays selected on the subform - indicated by the arrow on the left in datasheet view.

I've been toying with just moving the record to the first record on the subform with the timerevent. But the problem is when there is only one record in the subform to go to. This still leave that record selected. So I'm really wanting to unselect any record in the subform.

Any ideas?
 
Have you made sure the recordset for the subform is read only and therefore not locking anything?
 
Also, when you make the necessary changes you're not saving the record so it's still in edit mode and hence the write conflict. Once changes are made to the record, explicitly save the record in code.
 
Yes, the subform is read only.
HOW is it read-only? Is it read only because of the QUERY behind it or because you have set the Allow Edits property to NO?

You would need to do it in the QUERY, I believe to make it truly read only so that Access didn't care about it being open and selected.

To make it read only you can just set a grouping on the query or you can select properties from right clicking on the gray area where the tables are located in the QBE grid. You then change the Recordset Type from Dynaset to Snapshot.
 
vbaInet and Bob, thanks for the suggestions. I'll check my code and apply what you have indicated. It may take a day or two to find out if this will work.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom