

   If Ctrl.Form.Hwnd = oForm.Hwnd Then
      blnIsA_Sub = True
   End If   If Ctrl.Form Is oForm Then
      blnIsA_Sub = True
   End If   blnIsA_Sub = Ctrl.Form Is oFormProperty Get MeIsASubform As Boolean
   On Error Resume Next
   MeIsASubform = Left(Typename(Me.Parent), 4) = "Form"
End PropertyPrivate m_ccgA as cControlGroup
Private m_ccgB as cControlGroup
Property Get GroupA As cControlGroup
   If m_ccgA Is Nothing then 
      Set m_ccgA = New cControlGroup
      m_ccgA.Load [COLOR="Blue"]Me.Text0, Me.Text2, Me.Text[/COLOR]
   End If
   Set GroupA = m_ccgA
End Property
Property Get GroupB As cControlGroup
   If m_ccgB Is Nothing then 
      Set m_ccgB = New cControlGroup
      m_ccgB.Load [COLOR="blue"]Me.cmd1, Me.cmd2, Me.cmd3[/COLOR]
   End If
   Set GroupB = m_ccgB
End Property
Private Sub Text0_AfterUpdate()
   Me.GroupB.Enabled = Me.GroupA.HasNoNullValue
End Sub
BUT whether I'd do it again like this if I started again now is another matter...
That's the ultimate question!
The answer is 42....
as a personal reference to re-check some rarely used & obscure code which in my view was a bit of a muddle i.e."what's the meaning of life, the universe and everything?"
Hopefully the connection is obvious...at sixes and sevens
"At sixes and sevens" is an English idiom used to describe a condition of confusion or disarray.

I do not get an error running your code from the load event of a subform.
Thanks, this is OLD, but I found my solution, I just tweak it a bit.I wouldn’t do it in each instance of the subform, I’d do it from the Main Form….
Also, I'm uncomfortable when an Error is triggered deliberately to make something happen. However, it can't be avoided all of the time and is sometimes a necessary evil.
In this particular case I can see a way which would avoid such an abuse of MS Access!
I would look at the problem from a different perspective.
There's no such thing as a “Sub-Form”! What you have on your “Main Form” is an ordinary form housed within a subform/subreport control, which I refer to as a subform window. The term “Subform” is a useful way of explaining what you see, however the term does tend to take your eye off the ball so to speak, because the form (Subform) isn’t actually on the Main Form it actually resides within the subform/subreport control.
There is a natural tendency to think about Controls, Forms, Objects as individual entities, however most things in MS Access are members of a collection. There's no exception in this case, your command button is one of the controls in the controls collection of the form it’s on. The form itself is housed within the subform window. It’s not necessary to refer to this form by its full name, you just refer to it as an object, as the object contained within that subform window a “Form”
Once you think about writing your code to take advantage of these Collections of Controls, then there are loads of fascinating and interesting things you can do. In this case, I would approach the problem from the “Main Form” perspective, not the subform perspective.
I would write code in the main form that would traverse the Main Form’s Controls Collection when the main form loads.
in your main form's “Load Event” (the form housing all of the identical subforms), run the code below. The code will seek out all of your subforms it will look in each form and see if it has a command button named “btnToHide” and set it's visible property to false...
Code:Private Sub Form_Load() Dim Ctrl As Control For Each Ctrl In Me.Controls Select Case Ctrl.ControlType Case acSubform Ctrl.Form.btnToHide.Visible = False End Select Next Ctrl End Sub 'Form_Load
' 
Private Sub Form_Load()
Code by @Uncle Gizmo [AWF]
' https://www.access-programmers.co.uk/forums/threads/is-form-being-loaded-as-a-subform.297204/
'
Dim Ctrl As Control
For Each Ctrl In Me.Controls
    Select Case Ctrl.ControlType
        Case acSubform
            'Ctrl.Form.btnToHide.Visible = False
            ' Stops the Subform from Loading ?
            Me.AuthorizationsView.Enabled = False
            Me.AuthorizationsView.SourceObject = "AuthFullViewDummyF"
            
            
    End Select
Next Ctrl
End SubPrivate Sub Form_Load()
    'Code by @Uncle Gizmo [AWF]
    'https://www.access-programmers.co.uk/forums/threads/is-form-being-loaded-as-a-subform.297204/
    
    Dim Ctrl As Control
    For Each Ctrl In Me.Controls
    
        Select Case Ctrl.ControlType
            Case acSubform
                ' Example code where we're using a With statement
                With Me.AuthorizationsView
                    .Enabled = False
                    .SourceObject = "AuthFullViewDummyF"
                End With
                
        End Select
        
    Next Ctrl
End SubThank you, sir, I am working in a small option, if it works, I will post it.Hi Morris,
Great code! I made a small tweak by wrapping the Me.AuthorizationsView lines in a With statement for a bit of extra clarity and efficiency. It’s not essential here, but useful if more properties get added in the future.
Code:Private Sub Form_Load() 'Code by @Uncle Gizmo [AWF] 'https://www.access-programmers.co.uk/forums/threads/is-form-being-loaded-as-a-subform.297204/ Dim Ctrl As Control For Each Ctrl In Me.Controls Select Case Ctrl.ControlType Case acSubform ' Example code where we're using a With statement With Me.AuthorizationsView .Enabled = False .SourceObject = "AuthFullViewDummyF" End With End Select Next Ctrl End Sub
