McGurk1
asked on
Get form name using a global variable
I need to be able to capture the name of a form in a global variable. I saw one thread but it didn't make much sense to me. Will find it and add it to this thread. There must be a good way to get the name.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked like a dream!! You have the points. Can you help me with one more aspect. How do I use this global variable to reference a control on the form. It tells me the control is not a part of the form. However it is and I can see it when I hold the cursor over the variable. I am using the global variable in a second form. When I don't use the global variable and just use the formname.control name, it does not error. I need to use the second form to reference different forms to update them so that is why I need to use a global varialbe for the form name.
You need to CAST that form reference from a generic FORM (which is what OpenForms() returns), to the correct form type that you know it to be.
For instance, if you know that form is of type frmCatalog, then do:
Dim cat As frmCatalog = CType(GenericFormReference Here, frmCatalog)
Now you can use "cat" to get to the controls that are present on the frmCatalog type.
For instance, if you know that form is of type frmCatalog, then do:
Dim cat As frmCatalog = CType(GenericFormReference
Now you can use "cat" to get to the controls that are present on the frmCatalog type.
ASKER
Idle_Mind,
Thank you so much. I wish I could give you some points for this. It works great!
Thank you so much. I wish I could give you some points for this. It works great!
No problem.
*I wouldn't post in CLOSED questions if I was worried about points! ;)
*I wouldn't post in CLOSED questions if I was worried about points! ;)
Thanks for help idle_mind while I transitioned from work to home. Zone is to you now as I will spend next 3 hours in garden!
Happy gardening! ...fresh air and sunlight can't be found in a processor! ;)
ASKER
https://www.experts-exchange.com/questions/26722323/How-to-access-a-form-by-name-using-a-variable.html