Which is the "active" userform

Hi all,
I use the = new syntax when I display a userform.  e.g.

I have built a form called Frm_Status

In my stanndard code :
Dim F_Status as Frm_Status
set F_Status = new Frm_Status

So I am creating a new object called F_Status that is a copy of Frm_Status.

When I am in the Sub that "set" the userform, I can update F_Status and adjust it by  addressing it as F_Status.controlname .  However, in a different called Sub, I can't address the active F_Status form that is displayed.

I can find it by:
For Each oForm in Userforms()

but is there another way?

Hope this is clear ...

Who is Participating?
RODELSAuthor Commented:
Hi guys,
Thank you for the suggestions - neither of which worked.

I solved it myself using the following steps:
1) Created a public variable called goActive_Userform as msforms.userform

Then in the Initialise Form event -
set goActive_Userform = Me

Then in the calling module, refer to the form via goActive_Userform.controls( whatever

This seems to work.

Kind regards,
NorieVBA ExpertCommented:
Couldn't you pass the new instance you've created to the other sub, just as you would with any other variable/object.
Alternatively, you could create a public variable, rather than a local variable, as follows

Public F_Status as Frm_status

and comment out your current declaration.  That should give you an opening to engage the userform.

NorieVBA ExpertCommented:

How did you try what was suggested?
RODELSAuthor Commented:
It seems to work
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.