Not allowing edit in a main form disabling edits in a subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wassimdaccache
    New Member
    • Apr 2007
    • 222

    Not allowing edit in a main form disabling edits in a subform

    Dear Friend


    Working on access 2007 sp2.

    My form is consisting from a form and a subform.

    while i am using the alowedits=no option on the property of the main form it is preventing me to edit my subform.

    Is there any method where I will be able to stop edit in the main form while the subform still editable ?

    I don't want to go through VBA because I do have many attributes and action on this forms...

    Thank you in advance

    Regards
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    Wassim, Your question seems to be the opposite of the title. What is it you're asking about exactly?

    Comment

    • wassimdaccache
      New Member
      • Apr 2007
      • 222

      #3
      Sorry About the subject I was trying to say
      while I disable edit in the main form, access is disabling edits in the subform too

      the question is:

      Is there any method where I will be able to stop edit in the main form while the subform still editable ?

      Thank you

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        You'll need to loop thru the controls on the main form, and if the control type is not subform, lock it.

        Code:
        Private Sub Form_Load()
        Dim ctrl As Control
        
        For Each ctrl In Me.Controls
         If (TypeOf ctrl Is TextBox) Or (TypeOf ctrl Is ComboBox) Then
           ctrl.Locked = True
         End If
        Next
        
        End Sub
        This locks textboxes and comboboxes, if you have other controls on the main form that need locking, you simply add them to the

        If (TypeOf ctrl Is TextBox) Or (TypeOf ctrl Is ComboBox)

        line in a like manner.

        Linq ;0)>

        Comment

        • Megalog
          Recognized Expert Contributor
          • Sep 2007
          • 378

          #5
          Go to the subform's form properties, and be sure the Allow Edits is set to YES.
          I just tested this on a new form/subform and it worked fine with the main form locked down, but I had to then change the subform's property back to allow edits there.

          If you are locking down the main form with VBA, then basically follow that statement with another line to ENABLE the edits for the subform. It may be that access is automatically propogating that property from the main form, to the subform?

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            If AllowEdits is set to No on the main form, then no control on the main form can be editied, including the subform control! That's why the only way to handle this is as I've suggested. You have to lock all controls on the main form except the subform control.

            Linq ;0)>

            Comment

            • Megalog
              Recognized Expert Contributor
              • Sep 2007
              • 378

              #7
              I stand corrected, Linq is right as usual ;)

              I could've sworn I had it working in a test db.. then I created one from scratch and couldnt get it to work as I had said.

              Comment

              • wassimdaccache
                New Member
                • Apr 2007
                • 222

                #8
                Thanks all. I am doing the loop to lock all my control..

                Regards

                Comment

                • missinglinq
                  Recognized Expert Specialist
                  • Nov 2006
                  • 3533

                  #9
                  Glad we could help!

                  Linq ;0)>

                  Comment

                  Working...