Set Allow Edits on a subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jschmidt
    New Member
    • Jun 2007
    • 47

    Set Allow Edits on a subform

    Hello,

    I am using MS Access 2003 to create an inventory and ordering database. After an order is processed I disable that order by setting the main form's Allow Edits property to false. This effectively prevents the user from changing the details of the order.

    The problem shows up when the user gets to a order that has not been processed. The main form is unlocked for the user to edit but the subform and all the controls on the subform remain unusable.

    I need to know how to set the subform's allowedits propoerty in code.

    Here is what I thought would work but apparently it does not:
    Forms![Add an Order and Details].[Order_Details_S ubform].AllowEdits = True

    Does anyone know how to change the AllowEdits property on a subform? I am trying to do this in the Form_Current() event, in an if statement that evaluates a control on the main form. If the control holds a certain value then AllowEdits on the main form is set to true or false.

    Any help is appreciated. Thanks.
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi. You are very close with what you had. You just need to refer to the Form property of the subform, and set AllowEdits false (for disallow) or True (to allow):
    Code:
    Forms![Add an Order and Details].[Order_Details_Subform].Form.AllowEdits = False
    If you are referring to the subform from within the main form (from event code, for example) you can use the Me property to shorten the above to
    Code:
    Me![Order_Details_Subform].Form.AllowEdits = False
    -Stewart

    Comment

    • wassimdaccache
      New Member
      • Apr 2007
      • 222

      #3
      Originally posted by jschmidt
      Hello,

      I am using MS Access 2003 to create an inventory and ordering database. After an order is processed I disable that order by setting the main form's Allow Edits property to false. This effectively prevents the user from changing the details of the order.

      The problem shows up when the user gets to a order that has not been processed. The main form is unlocked for the user to edit but the subform and all the controls on the subform remain unusable.


      I need to know how to set the subform's allowedits propoerty in code.

      Here is what I thought would work but apparently it does not:
      Forms![Add an Order and Details].[Order_Details_S ubform].AllowEdits = True

      Does anyone know how to change the AllowEdits property on a subform? I am trying to do this in the Form_Current() event, in an if statement that evaluates a control on the main form. If the control holds a certain value then AllowEdits on the main form is set to true or false.

      Any help is appreciated. Thanks.
      I think you have to write this code
      me.order_detail s_subform.allow edits=true

      please try it and tell me if it works... If it doesn't I'll leave this subject to the expert.

      Have a nice day

      Comment

      • Stewart Ross
        Recognized Expert Moderator Specialist
        • Feb 2008
        • 2545

        #4
        Hi Wassim. AllowEdits is a property of the Form object. To refer to the subform's Form properties requires a qualification that would not be needed if it was the main form's Allow Edits that was being changed. Unfortunately what you have advised is the same (except for the use of the Me shortcut) as the original poster has already tried, and this will not succeed when applied to a subform unless the Form qualifier is used.

        -Stewart
        Originally posted by wassimdaccache
        I think you have to write this code
        me.order_detail s_subform.allow edits=true

        please try it and tell me if it works... If it doesn't I'll leave this subject to the expert.

        Have a nice day

        Comment

        • jschmidt
          New Member
          • Jun 2007
          • 47

          #5
          Got it! Thanks for the help and quick response!

          Comment

          • rabuayya
            New Member
            • Oct 2015
            • 1

            #6
            Thank you for the help. I had that problem too :)

            Comment

            Working...