View Single Post
 
Old 01-31-2018, 12:59 PM
Cosmo Cosmo is offline Windows Vista Office 2007
Competent Performer
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

For now, I have solved my issue with a bit of a hack. In the subFunction, I check the typeof the variable 'frm', and if it is 'Controls', I loop through the controls to get the parent UserForm. (NOTE, this won't work if there are no controls on the UserForm, but at least it is acceptable until I find a more proper way to make this work since that's never going to be the case in my program)

Code:
    If (TypeOf frm Is Controls) Then
        Dim ctrl As Control
        For Each ctrl In frm
            If (TypeOf ctrl.Parent Is UserForm) Then
                Set frm = ctrl.Parent
                Exit For
            End If
        Next
    End If
I'd prefer to code this properly, and not rely on this hack, so if anyone can tell me how to pass the userForm properly between the two functions, I would appreciate it very much.

Thanks.
Reply With Quote