Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    disable a control on a subform (AccessXP)

    Hi,

    I have a form with a tab control with sub forms on each page. When the Save button on the main form is clicked i want to disable all of the controls on all of the subforms.

    I am however coming across a problem, when i get to the point of disabling the controls on the sub form on which changes had just been made. If i enter changes into a text box and then click save, even though i have a line of code that moves the focus from the sub form to a command button on the main form the code falls over with the 'cannot disable a control that has the focus' error.

    Is there a focus for each form, even when the form is not active?

    How can i get around this problem please?

    TIA

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: disable a control on a subform (AccessXP)

    Yes, even if the subform as a whole doesn't have the focus, it remembers which control has the focus.

    Alternatives:
    <UL><LI>Instead of setting the Enabled property of the controls in the subform to False, set their Locked property to True. This has no influence on the focus.
    <LI>Disable the subform as a whole:

    Me.Subformname.Enabled = False

    However, this means that the user can't click in the subform any more (so scrolling is impossible.)
    <LI>Set the AllowEdits, AllowAdditions and AllowDeletions properties of the subform as a form to False:

    With Me.Subformname.Form
    AllowEdits = False
    AllowAdditions = False
    AllowDeletions = False
    End With[/list]You'll have to decide which is best in your situation.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: disable a control on a subform (AccessXP)

    three options <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> , many thanks HansV.

Posting Permissions

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