Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-31-2018, 12:59 PM
Cosmo Cosmo is offline Show userForm from variable Windows Vista Show userForm from variable Office 2007
Competent Performer
Show userForm from variable
 
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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Show userForm from variable Assigning a string variable to a userform label caption Larry_1 Excel Programming 3 12-18-2017 06:59 AM
Show userForm from variable Show Userform when Content Control CheckBox ticked derajlance Word VBA 1 05-13-2016 01:55 PM
Using Userform.Show in Excel 2013 BillCPA Excel Programming 0 05-04-2015 09:52 AM
Command button to show userform suddenly stopped working jpb103 Word VBA 0 05-22-2014 06:05 AM
Show userForm from variable Show userform without losing document focus? Or other method to get a graphic to pop? AlexR Word VBA 7 03-31-2013 12:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:49 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft