locking subforms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ken

    #1

    locking subforms

    Hi,
    I have a form that depending on certain criteria locks all of the
    subforms on this form. The problem is when the code unlocks the
    subforms their "allowedits " "allowdeletions " and "allowadditions "
    properties are set to "NO". I believe when the main form locks the
    subforms it sets these "allow" properties to "no". But when the
    subforms are unlocked the "allow" properties are not set back to "yes".
    I have all this code in the oncurrent event. Depending on the record
    that I'm in, the form is either locked or not.

    Anyhow I tried setting the "allow" properties to yes during the unlock
    opperation, but access gives me an error stating that the subforms
    don't have the allow properties...

    what am I doing wrong?

    thanks

  • Randy Harris

    #2
    Re: locking subforms


    "ken" <gevayl@gmail.c om> wrote in message
    news:1122157341 .807645.253140@ g47g2000cwa.goo glegroups.com.. .[color=blue]
    > Hi,
    > I have a form that depending on certain criteria locks all of the
    > subforms on this form. The problem is when the code unlocks the
    > subforms their "allowedits " "allowdeletions " and "allowadditions "
    > properties are set to "NO". I believe when the main form locks the
    > subforms it sets these "allow" properties to "no". But when the
    > subforms are unlocked the "allow" properties are not set back to "yes".
    > I have all this code in the oncurrent event. Depending on the record
    > that I'm in, the form is either locked or not.
    >
    > Anyhow I tried setting the "allow" properties to yes during the unlock
    > opperation, but access gives me an error stating that the subforms
    > don't have the allow properties...
    >
    > what am I doing wrong?
    >
    > thanks[/color]

    Just a suggestion Ken, but if you post your code there's a much better
    chance that someone will be able to tell you what is wrong with it.

    Comment

    • ken

      #3
      Re: locking subforms

      Private Sub Form_Current()
      If ([islocked]) Then
      'if true lock form
      Me.AllowEdits = False
      Me.AllowDeletio ns = False
      Me.AllowAdditio ns = False
      Me![Input subform].Locked = True
      Else
      'if false unlock form
      Me.AllowEdits = True
      Me.AllowDeletio ns = True
      Me.AllowAdditio ns = True
      Me![Input subform].Locked = False
      End If
      End Sub


      Basically when the if statement is false I could not do any data entry
      on the subform. I could on the main form though...I was looking through
      the properties while the form was on...and all the allow properties had
      a "No" in them...so I tried this:

      Private Sub Form_Current()
      If ([islocked]) Then
      'if true lock form
      Me.AllowEdits = False
      Me.AllowDeletio ns = False
      Me.AllowAdditio ns = False
      Me![Input subform].Locked = True
      Else
      'if false unlock form
      Me.AllowEdits = True
      Me.AllowDeletio ns = True
      Me.AllowAdditio ns = True
      Me![Input subform].Locked = False
      Me![Input subform].AllowEdits = True
      End If
      End Sub


      And I got error stating that the Me![Input subform] does not have an
      allowedits property...

      Comment

      • pietlinden@hotmail.com

        #4
        Re: locking subforms

        doesn't look like you're referring to the subform properly. Here's an
        article that gives examples of referring to just about everything in
        forms and subforms.



        I think this is the syntax that you want:

        Me!Subform1.For m.AllowEdits=Tr ue

        Comment

        • Randy Harris

          #5
          Re: locking subforms


          "ken" <gevayl@gmail.c om> wrote in message
          news:1122159358 .536153.320880@ g14g2000cwa.goo glegroups.com.. .[color=blue]
          > Private Sub Form_Current()
          > If ([islocked]) Then
          > 'if true lock form
          > Me.AllowEdits = False
          > Me.AllowDeletio ns = False
          > Me.AllowAdditio ns = False
          > Me![Input subform].Locked = True
          > Else
          > 'if false unlock form
          > Me.AllowEdits = True
          > Me.AllowDeletio ns = True
          > Me.AllowAdditio ns = True
          > Me![Input subform].Locked = False
          > End If
          > End Sub
          >
          >
          > Basically when the if statement is false I could not do any data entry
          > on the subform. I could on the main form though...I was looking through
          > the properties while the form was on...and all the allow properties had
          > a "No" in them...so I tried this:
          >
          > Private Sub Form_Current()
          > If ([islocked]) Then
          > 'if true lock form
          > Me.AllowEdits = False
          > Me.AllowDeletio ns = False
          > Me.AllowAdditio ns = False
          > Me![Input subform].Locked = True
          > Else
          > 'if false unlock form
          > Me.AllowEdits = True
          > Me.AllowDeletio ns = True
          > Me.AllowAdditio ns = True
          > Me![Input subform].Locked = False
          > Me![Input subform].AllowEdits = True
          > End If
          > End Sub
          >
          >
          > And I got error stating that the Me![Input subform] does not have an
          > allowedits property...[/color]

          Ken, I'm only guessing here, but I suspect that the procedure you are using
          is in the parent form, not the sub form. AllowEdits only applies to forms,
          not controls on forms, even sub form controls. To allow edits you will need
          to refer directly to the form with something like:

          Forms![Input subform].AllowEdits = True

          HTH



          Comment

          • ken

            #6
            Re: locking subforms

            ok I think that did it I have to do
            Me![Input subform].Form.AllowEdit s = True

            then it works

            Comment

            • ken

              #7
              Re: locking subforms

              does anyone know though why when you lock the form with .locked = true
              it sets all the allow properties to No, but when you unlock it does not
              set them back to yes?

              Comment

              • David W. Fenton

                #8
                Re: locking subforms

                "ken" <gevayl@gmail.c om> wrote in
                news:1122160871 .595686.315780@ z14g2000cwz.goo glegroups.com:
                [color=blue]
                > ok I think that did it I have to do
                > Me![Input subform].Form.AllowEdit s = True
                >
                > then it works[/color]

                The reason it works is because there's a distinction between the
                subform control that you place on a form and the actual subform
                contained in the subform control.

                If you turn off the wizards in form design, you can drop an empty
                subform control on a form. It has no Source Object property.

                The subform control has its own set of properties, separate from
                those of the subform that it is holding once you assign a Source
                Object property.

                Versions of Access since 2000 obscure this because of the brain-dead
                stupid interface that displays the subform in the control itself at
                all times (making it impossible to easily edit that form in
                instances where the size of the control is too small to fully
                display the design view of the form; this includes EVERY SUBFORM
                EVER, since the design view requires more screen real estate than
                the form view in all cases), but it's still there.

                Me![Input subform] is the subform control.

                whereas:

                Me![Input subform].Form is the form displayed in that subform
                control.

                I make a point of naming subforms subMyForm and the subform control
                MyForm to remind myself that MyForm is *not* itself a form, but a
                subform control.

                --
                David W. Fenton http://www.bway.net/~dfenton
                dfenton at bway dot net http://www.bway.net/~dfassoc

                Comment

                • gleave
                  New Member
                  • Mar 2006
                  • 5

                  #9
                  Hi, I also have a problem with subforms but what I want to do is slightly different. I want to lock a subform until all the required data is inputted in the main form.

                  The required fields in main form:
                  Invoice Number
                  Invoice to

                  Thank you

                  Comment

                  Working...