Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form.AllowEdits 2

Status
Not open for further replies.

jmodo

Programmer
Aug 2, 2006
43
US
I am trying to set this property programmatically. When I set the property manually in the form, it propogates down to all of the sub-forms, just like I want.
When I set the property programmatically, it doesn't propogate down to the subforms. Is there a way to call Form.AllowEdits programmatically and have it propogate to the subforms?

Thanks,
jmob
 
Put this code behind your form, and call it when you want to turn off editing on the main form and all subforms.

Code:
Private Sub DisallowAllEdits()
    Dim c As Control
    
    Me.AllowEdits = False
    For Each c In Me.Controls
        If c.ControlType = acSubform Then
            c.Form.AllowEdits = False
        End If
    Next c
End Sub

Error handling is not included, for brevity's sake.

You can generalize it to turn on editing, too. I'll leave that up to you.
 
I need the code to include subforms within subforms. I tried replicating the code to include the sub-subforms, but I can't get it to work. Can you help me a little further?
Thanks!
 
Typed, untested:
Code:
Private Sub DisallowAllEdits()
Dim c As Control, sc As Control
Me.AllowEdits = False
For Each c In Me.Controls
    If c.ControlType = acSubform Then
        c.Form.AllowEdits = False
        For Each sc In c.Form.Controls
            If sc.ControlType = acSubform Then
                sc.Form.AllowEdits = False
            End If
        Next sc
    End If
Next c
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top