I am trying to loop through each panel and control in each user form I have in my application so I wrote a subroutine to call upon initialization of each user form. The problem I have encountered is referencing the sender user form in a separate module. The code I have:
Sub Configure_UI()
For Each Control_Panel As Panel In sender.Controls.OfType(Of Panel) 'Loop through panels
For Each control In Control_Panel.Controls
Configure_Control(control)
Next
Next
End Sub
The error that it gives says "Sender is not declared. It may be inaccessible due to its protection level.". SO I wonder how do I fix this. What I need is a dynamic solution where sender is the form.name.
Could someone, please, help me out please?
so the solution is as follows
and the call to it from user form initialization is:
Any suggestions on optimizing the solution?