Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reference the controls of a subform from a global function

I am trying to run the below global function. I am basically passing it the name of the form and cycling through the controls to get the before and after values. This has been working fine up until I wanted to capture the values from a sub form. I recently added the Optional tempParentFormName As String parameter. Now I am trying to get the syntax right for the controls of the sub form. Forms(tempParentFormName).Form(funFormName).Controls is not working. What should it be? The version for a from without a sub (Forms(funFormName).Controls) works fine.

Public Function funDeleteGetFieldValues(funFormName As String, 
                                        tempFieldsValues1 As String, 
                                        tempFieldsValues2 As String, 
                                        Optional tempParentFormName As String)
    Dim ctl As Control, tempProperControl As Boolean, tempCounter As Integer
    tempCounter = 1
    tempFieldsValues1 = ""
    tempFieldsValues2 = ""
    
    For Each ctl In Forms(tempParentFormName).Form(funFormName).Controls
        'A bunch of code
    Next ctl
    Set ctl = Nothing
End Function

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It is the subform control to use:

Forms(tempParentFormName)(subformControlName).Form.Controls
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading