Home > Mobile >  Reference the controls of a subform from a global function
Reference the controls of a subform from a global function

Time:08-16

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

CodePudding user response:

It is the subform control to use:

Forms(tempParentFormName)(subformControlName).Form.Controls
  • Related