By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,939 Members | 611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,939 IT Pros & Developers. It's quick & easy.

How to refere a form by name if the name is stored into a variable ?

100+
P: 759
Hi !
I have a variable (strFormName as String) where I have stored the name of a form.
Is it possible to refer that form by using the stored name ?
Something like this:

Form(strFormName).Visible = True

Thank you !

Note please that I know how to loop to every form in Forms collection until I find the desired form.
This is not what I am looking for.
Jul 9 '12 #1

✓ answered by MikeTheBike

Hi

Yes is the answer, which you very nearly have already. The Forms collection is access by
Forms(strFormName).Visible = True

ie you just need as s in Forms.

It is necessary for the form to be Open/Loaded for this to work.

HTH

Share this Question
Share on Google+
3 Replies


Expert 100+
P: 634
Hi

Yes is the answer, which you very nearly have already. The Forms collection is access by
Forms(strFormName).Visible = True

ie you just need as s in Forms.

It is necessary for the form to be Open/Loaded for this to work.

HTH
Jul 9 '12 #2

TheSmileyCoder
Expert Mod 100+
P: 2,321
Just to add to a allready good answer, you can check whether the form is open by checking the property:
Expand|Select|Wrap|Line Numbers
  1. currentproject.AllForms(strFormName).IsLoaded
Jul 9 '12 #3

100+
P: 759
Thank you, Mike and thank you Smiley !
I don't know (until now) the .IsLoaded feature. Very good to know this. Thank you again !
Jul 9 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.