Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2003
    Posts
    66

    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?

  2. #2
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    Instead of having subform 2 on the form, you could get it to popup in its own window and make it modal. This will require the user to finish what was started.

  3. #3
    Join Date
    Nov 2003
    Posts
    66
    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)

    D

  4. #4
    Join Date
    Nov 2003
    Posts
    267
    SubFOrmObjectName.Enabled = False

    S-

  5. #5
    Join Date
    Nov 2003
    Posts
    66
    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.

    D

  6. #6
    Join Date
    Nov 2003
    Posts
    267
    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.


    To overcome this problem, move the focus to another object. SOmething as simple as

    me.textbox.setfocus
    SubFOrmObjectName.Enabled = False


    This way the focus is nolonger on the subform and it will become disabled

    S-

  7. #7
    Join Date
    Nov 2003
    Posts
    66
    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....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •