Unanswered: lock or disable a subform displayed in datasheet view
Hi, I'm a bit of a novice, so apologies if this seems pretty basic....
I have a main form on which the user selects a name from a dropdown. This selection populates a subform (in datasheet view) of records associated with the selected name. User selects a row from the datasheet, and the entire details for the selected record are then displayed in a second subform (form view). User clicks a button, held on subform 2, which unlocks it's fields, and they can then go ahead and edit the record.
Problem - if the user is currently editing a record, they can go back to the datasheet list, select a new record, and begin editing that - any changes they made to the one they were previously on, are automatically retained without the user explicitly clicking my 'save' button. I want to prevent this by locking the datasheet listing (subform1) while the second subform is enabled.
While the button for enabling subform 2 for editing works fine, when I try and add a macro to it to disable subform 1 at the same time, Access tells me it can't find subform 1. I've tried adding a field to the main form which is populated with a value once subform 2 is enabled, and then running a macro to disable subform1 based on the condition that this value is present, but that doesn't work either. The option to lock or disable the form isn't present in the expression builder, and locking the individual fields doesn't work.
Is it actually possible to disable or lock a subform if it's displayed in datasheet view at all?
Cheers - hadn't thought of that. Don't have time to go back and re-work it though. I'll just make the user's aware and tell them it's a 'feature'...!
(and that their PC will explode if they jump from record to record too much)
Cheers for that - I did try disabling it using the above, (once I worked out how to get the system to actually recognise the subform) but the system wouldn't allow it.
Because I'm using subforms, when the user makes a selection from the datasheet to display that record's full details, the focus actually remains on the record selected in the datasheet, and also displays a new focus in the editable subform. Then, on trying to set the value of the datasheet, or any of it's fields, to 'locked' or 'disabled', the system tells me it can't lock an object that has the focus. Much cursing followed that particular error message....
Thanks anyway - decided to move on and leave it as is.
Tried that too! The button I'm using to try triggering the enable/disable on the datasheet, also sends the focus on the editing form to the first editable field on that form. Can't see how it could also reset the focus from the datasheet that selected the record in the first place. Bear in mind that the form I'm trying to disable is a datasheet, so there isn't really anywhere on it that I could send the focus to....